test_data

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: AGPL-3.0 Imports: 17 Imported by: 0

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,
		Err:          nil,
	}

	EmptyStatediffPayload = statediff.Payload{
		BlockRlp:     []byte{},
		StateDiffRlp: []byte{},
		Err:          nil,
	}

	ErrStatediffPayload = statediff.Payload{
		BlockRlp:     []byte{},
		StateDiffRlp: []byte{},
		Err:          errors.New("mock error"),
	}
)
View Source
var GenericModel = event.InsertionModel{}
View Source
var GenericTestConfig = transformer.EventTransformerConfig{
	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 CreateTestLog added in v0.0.9

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

Create a header sync log to reference in an event, returning inserted header sync log

Types

This section is empty.

Jump to

Keyboard shortcuts

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