test_data

package
v0.0.15-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2020 License: AGPL-3.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BlockNumber             = big.NewInt(rand.Int63())
	BlockHash               = "0xfa40fbe2d98d98b3363a778d52f2bcd29d6790b9b3f3cab2b167fd12d3550f73"
	CodeHash                = common.Hex2Bytes("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
	NewNonceValue           = rand.Uint64()
	NewBalanceValue         = rand.Int63()
	ContractRoot            = common.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
	StoragePath             = common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470").Bytes()
	StorageKey              = common.HexToHash("0000000000000000000000000000000000000000000000000000000000000001").Bytes()
	SmallStorageValue       = common.Hex2Bytes("03")
	SmallStorageValueRlp, _ = rlp.EncodeToBytes(SmallStorageValue)

	LargeStorageValue       = common.Hex2Bytes("00191b53778c567b14b50ba0000")
	LargeStorageValueRlp, _ = rlp.EncodeToBytes(LargeStorageValue)

	EmptyStorage        = make([]statediff.StorageDiff, 0)
	StorageWithBadValue = statediff.StorageDiff{
		Key:   StorageKey,
		Value: []byte{0, 1, 2},
	}

	ContractLeafKey = crypto.Keccak256Hash(contractAddress[:])

	AnotherContractLeafKey = crypto.Keccak256Hash(anotherContractAddress[:])

	CreatedAccountDiffs = []statediff.AccountDiff{
		{
			Key:     ContractLeafKey.Bytes(),
			Value:   valueBytes,
			Storage: storageWithSmallValue,
		},
	}

	UpdatedAccountDiffs = []statediff.AccountDiff{{
		Key:     AnotherContractLeafKey.Bytes(),
		Value:   valueBytes,
		Storage: storageWithLargeValue,
	}}

	DeletedAccountDiffs = []statediff.AccountDiff{{
		Key:     AnotherContractLeafKey.Bytes(),
		Value:   valueBytes,
		Storage: storageWithSmallValue,
	}}

	MockStateDiff = statediff.StateDiff{
		BlockNumber:     BlockNumber,
		BlockHash:       common.HexToHash(BlockHash),
		CreatedAccounts: CreatedAccountDiffs,
		DeletedAccounts: DeletedAccountDiffs,
		UpdatedAccounts: UpdatedAccountDiffs,
	}
	MockStateDiffBytes, _ = rlp.EncodeToBytes(MockStateDiff)

	MockTransactions = types.Transactions{mockTransaction1, mockTransaction2}

	MockReceipts = types.Receipts{mockReceipt1, mockReceipt2}

	MockHeader = types.Header{
		Time:        0,
		Number:      BlockNumber,
		Root:        common.HexToHash("0x0"),
		TxHash:      common.HexToHash("0x0"),
		ReceiptHash: common.HexToHash("0x0"),
	}
	MockBlock       = types.NewBlock(&MockHeader, MockTransactions, nil, MockReceipts)
	MockBlockRlp, _ = rlp.EncodeToBytes(MockBlock)

	MockStatediffPayload = statediff.Payload{
		BlockRlp:     MockBlockRlp,
		StateDiffRlp: MockStateDiffBytes,
	}
)
View Source
var GenericTestConfig = event.TransformerConfig{
	TransformerName:     "generic-test-transformer",
	ContractAddresses:   []string{FakeAddress().Hex()},
	ContractAbi:         randomString(100),
	Topic:               topic0,
	StartingBlockNumber: startingBlockNumber,
	EndingBlockNumber:   startingBlockNumber + 1,
}
View Source
var GenericTestLog = func() types.Log {
	return types.Log{
		Address:     FakeAddress(),
		Topics:      []common.Hash{common.HexToHash(topic0), FakeHash()},
		Data:        hexutil.MustDecode(FakeHash().Hex()),
		BlockNumber: uint64(startingBlockNumber),
		TxHash:      FakeHash(),
		TxIndex:     uint(rand.Int31()),
		BlockHash:   FakeHash(),
		Index:       uint(rand.Int31()),
	}
}

Functions

func CreateMatchingTx added in v0.1.0

func CreateMatchingTx(log types.Log, headerID int64, headerRepo datastore.HeaderRepository)

func CreateTestLog added in v0.0.10

func CreateTestLog(headerID int64, db *postgres.DB) core.EventLog

Create an event log to reference in an event, returning inserted event log

func FakeAddress added in v0.1.0

func FakeAddress() common.Address

func FakeHash added in v0.1.0

func FakeHash() common.Hash

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL