update tests

This commit is contained in:
Sina Mahmoodi 2025-05-23 15:45:16 +02:00
parent 3bcadb7db7
commit d777eed431

View file

@ -680,26 +680,28 @@ func makeTestReceipts(n int, nPerBlock int) []types.Receipts {
} }
type fullLogRLP struct { type fullLogRLP struct {
Address common.Address Address common.Address
Topics []common.Hash Topics []common.Hash
Data []byte Data []byte
BlockNumber uint64 BlockNumber uint64
TxHash common.Hash BlockTimestamp uint64
TxIndex uint TxHash common.Hash
BlockHash common.Hash TxIndex uint
Index uint BlockHash common.Hash
Index uint
} }
func newFullLogRLP(l *types.Log) *fullLogRLP { func newFullLogRLP(l *types.Log) *fullLogRLP {
return &fullLogRLP{ return &fullLogRLP{
Address: l.Address, Address: l.Address,
Topics: l.Topics, Topics: l.Topics,
Data: l.Data, Data: l.Data,
BlockNumber: l.BlockNumber, BlockNumber: l.BlockNumber,
TxHash: l.TxHash, BlockTimestamp: l.BlockTimestamp,
TxIndex: l.TxIndex, TxHash: l.TxHash,
BlockHash: l.BlockHash, TxIndex: l.TxIndex,
Index: l.Index, BlockHash: l.BlockHash,
Index: l.Index,
} }
} }
@ -834,7 +836,7 @@ func TestDeriveLogFields(t *testing.T) {
// Derive log metadata fields // Derive log metadata fields
number := big.NewInt(1) number := big.NewInt(1)
hash := common.BytesToHash([]byte{0x03, 0x14}) hash := common.BytesToHash([]byte{0x03, 0x14})
types.Receipts(receipts).DeriveFields(params.TestChainConfig, hash, number.Uint64(), 0, big.NewInt(0), big.NewInt(0), txs) types.Receipts(receipts).DeriveFields(params.TestChainConfig, hash, number.Uint64(), 12, big.NewInt(0), big.NewInt(0), txs)
// Iterate over all the computed fields and check that they're correct // Iterate over all the computed fields and check that they're correct
logIndex := uint(0) logIndex := uint(0)
@ -846,6 +848,9 @@ func TestDeriveLogFields(t *testing.T) {
if receipts[i].Logs[j].BlockHash != hash { if receipts[i].Logs[j].BlockHash != hash {
t.Errorf("receipts[%d].Logs[%d].BlockHash = %s, want %s", i, j, receipts[i].Logs[j].BlockHash.String(), hash.String()) t.Errorf("receipts[%d].Logs[%d].BlockHash = %s, want %s", i, j, receipts[i].Logs[j].BlockHash.String(), hash.String())
} }
if receipts[i].Logs[j].BlockTimestamp != 12 {
t.Errorf("receipts[%d].Logs[%d].BlockTimestamp = %d, want %d", i, j, receipts[i].Logs[j].BlockTimestamp, 12)
}
if receipts[i].Logs[j].TxHash != txs[i].Hash() { if receipts[i].Logs[j].TxHash != txs[i].Hash() {
t.Errorf("receipts[%d].Logs[%d].TxHash = %s, want %s", i, j, receipts[i].Logs[j].TxHash.String(), txs[i].Hash().String()) t.Errorf("receipts[%d].Logs[%d].TxHash = %s, want %s", i, j, receipts[i].Logs[j].TxHash.String(), txs[i].Hash().String())
} }