core/types: test receipt.logs marshal with time

Signed-off-by: tmelhao <tmelhao@gmail.com>
This commit is contained in:
tmelhao 2024-06-03 10:03:53 +00:00
parent aca0eb5c54
commit 728c381ade

View file

@ -165,21 +165,23 @@ var (
Address: common.BytesToAddress([]byte{0x11}), Address: common.BytesToAddress([]byte{0x11}),
Topics: []common.Hash{common.HexToHash("dead"), common.HexToHash("beef")}, Topics: []common.Hash{common.HexToHash("dead"), common.HexToHash("beef")},
// derived fields: // derived fields:
BlockNumber: blockNumber.Uint64(), BlockNumber: blockNumber.Uint64(),
TxHash: txs[0].Hash(), TxHash: txs[0].Hash(),
TxIndex: 0, TxIndex: 0,
BlockHash: blockHash, BlockHash: blockHash,
Index: 0, Index: 0,
BlockTimestamp: blockTime,
}, },
{ {
Address: common.BytesToAddress([]byte{0x01, 0x11}), Address: common.BytesToAddress([]byte{0x01, 0x11}),
Topics: []common.Hash{common.HexToHash("dead"), common.HexToHash("beef")}, Topics: []common.Hash{common.HexToHash("dead"), common.HexToHash("beef")},
// derived fields: // derived fields:
BlockNumber: blockNumber.Uint64(), BlockNumber: blockNumber.Uint64(),
TxHash: txs[0].Hash(), TxHash: txs[0].Hash(),
TxIndex: 0, TxIndex: 0,
BlockHash: blockHash, BlockHash: blockHash,
Index: 1, Index: 1,
BlockTimestamp: blockTime,
}, },
}, },
// derived fields: // derived fields:
@ -199,21 +201,23 @@ var (
Address: common.BytesToAddress([]byte{0x22}), Address: common.BytesToAddress([]byte{0x22}),
Topics: []common.Hash{common.HexToHash("dead"), common.HexToHash("beef")}, Topics: []common.Hash{common.HexToHash("dead"), common.HexToHash("beef")},
// derived fields: // derived fields:
BlockNumber: blockNumber.Uint64(), BlockNumber: blockNumber.Uint64(),
TxHash: txs[1].Hash(), TxHash: txs[1].Hash(),
TxIndex: 1, TxIndex: 1,
BlockHash: blockHash, BlockHash: blockHash,
Index: 2, Index: 2,
BlockTimestamp: blockTime,
}, },
{ {
Address: common.BytesToAddress([]byte{0x02, 0x22}), Address: common.BytesToAddress([]byte{0x02, 0x22}),
Topics: []common.Hash{common.HexToHash("dead"), common.HexToHash("beef")}, Topics: []common.Hash{common.HexToHash("dead"), common.HexToHash("beef")},
// derived fields: // derived fields:
BlockNumber: blockNumber.Uint64(), BlockNumber: blockNumber.Uint64(),
TxHash: txs[1].Hash(), TxHash: txs[1].Hash(),
TxIndex: 1, TxIndex: 1,
BlockHash: blockHash, BlockHash: blockHash,
Index: 3, Index: 3,
BlockTimestamp: blockTime,
}, },
}, },
// derived fields: // derived fields:
@ -523,6 +527,7 @@ func clearComputedFieldsOnLogs(logs []*Log) []*Log {
cpy.TxHash = common.Hash{} cpy.TxHash = common.Hash{}
cpy.TxIndex = math.MaxUint32 cpy.TxIndex = math.MaxUint32
cpy.Index = math.MaxUint32 cpy.Index = math.MaxUint32
cpy.BlockTimestamp = math.MaxUint32
l[i] = &cpy l[i] = &cpy
} }
return l return l