@@ -33,14 +33,34 @@ func TestChainIterator(t *testing.T) {
33
33
34
34
var block * types.Block
35
35
var txs []* types.Transaction
36
- for i := uint64 (0 ); i <= 10 ; i ++ {
37
- if i == 0 {
38
- block = types .NewBlock (& types.Header {Number : big .NewInt (int64 (i ))}, nil , nil , nil , newHasher ()) // Empty genesis block
36
+ to := common .BytesToAddress ([]byte {0x11 })
37
+ block = types .NewBlock (& types.Header {Number : big .NewInt (int64 (0 ))}, nil , nil , nil , newHasher ()) // Empty genesis block
38
+ WriteBlock (chainDb , block )
39
+ WriteCanonicalHash (chainDb , block .Hash (), block .NumberU64 ())
40
+ for i := uint64 (1 ); i <= 10 ; i ++ {
41
+ var tx * types.Transaction
42
+ if i % 2 == 0 {
43
+ tx = types .NewTx (& types.LegacyTx {
44
+ Nonce : i ,
45
+ GasPrice : big .NewInt (11111 ),
46
+ Gas : 1111 ,
47
+ To : & to ,
48
+ Value : big .NewInt (111 ),
49
+ Data : []byte {0x11 , 0x11 , 0x11 },
50
+ })
39
51
} else {
40
- tx := types .NewTransaction (i , common .BytesToAddress ([]byte {0x11 }), big .NewInt (111 ), 1111 , big .NewInt (11111 ), []byte {0x11 , 0x11 , 0x11 })
41
- txs = append (txs , tx )
42
- block = types .NewBlock (& types.Header {Number : big .NewInt (int64 (i ))}, []* types.Transaction {tx }, nil , nil , newHasher ())
52
+ tx = types .NewTx (& types.AccessListTx {
53
+ ChainID : big .NewInt (1337 ),
54
+ Nonce : i ,
55
+ GasPrice : big .NewInt (11111 ),
56
+ Gas : 1111 ,
57
+ To : & to ,
58
+ Value : big .NewInt (111 ),
59
+ Data : []byte {0x11 , 0x11 , 0x11 },
60
+ })
43
61
}
62
+ txs = append (txs , tx )
63
+ block = types .NewBlock (& types.Header {Number : big .NewInt (int64 (i ))}, []* types.Transaction {tx }, nil , nil , newHasher ())
44
64
WriteBlock (chainDb , block )
45
65
WriteCanonicalHash (chainDb , block .Hash (), block .NumberU64 ())
46
66
}
@@ -66,7 +86,7 @@ func TestChainIterator(t *testing.T) {
66
86
numbers = append (numbers , int (h .number ))
67
87
if len (h .hashes ) > 0 {
68
88
if got , exp := h .hashes [0 ], txs [h .number - 1 ].Hash (); got != exp {
69
- t .Fatalf ("hash wrong, got %x exp %x" , got , exp )
89
+ t .Fatalf ("block %d: hash wrong, got %x exp %x" , h . number , got , exp )
70
90
}
71
91
}
72
92
}
@@ -88,14 +108,37 @@ func TestIndexTransactions(t *testing.T) {
88
108
89
109
var block * types.Block
90
110
var txs []* types.Transaction
91
- for i := uint64 (0 ); i <= 10 ; i ++ {
92
- if i == 0 {
93
- block = types .NewBlock (& types.Header {Number : big .NewInt (int64 (i ))}, nil , nil , nil , newHasher ()) // Empty genesis block
111
+ to := common .BytesToAddress ([]byte {0x11 })
112
+
113
+ // Write empty genesis block
114
+ block = types .NewBlock (& types.Header {Number : big .NewInt (int64 (0 ))}, nil , nil , nil , newHasher ())
115
+ WriteBlock (chainDb , block )
116
+ WriteCanonicalHash (chainDb , block .Hash (), block .NumberU64 ())
117
+
118
+ for i := uint64 (1 ); i <= 10 ; i ++ {
119
+ var tx * types.Transaction
120
+ if i % 2 == 0 {
121
+ tx = types .NewTx (& types.LegacyTx {
122
+ Nonce : i ,
123
+ GasPrice : big .NewInt (11111 ),
124
+ Gas : 1111 ,
125
+ To : & to ,
126
+ Value : big .NewInt (111 ),
127
+ Data : []byte {0x11 , 0x11 , 0x11 },
128
+ })
94
129
} else {
95
- tx := types .NewTransaction (i , common .BytesToAddress ([]byte {0x11 }), big .NewInt (111 ), 1111 , big .NewInt (11111 ), []byte {0x11 , 0x11 , 0x11 })
96
- txs = append (txs , tx )
97
- block = types .NewBlock (& types.Header {Number : big .NewInt (int64 (i ))}, []* types.Transaction {tx }, nil , nil , newHasher ())
130
+ tx = types .NewTx (& types.AccessListTx {
131
+ ChainID : big .NewInt (1337 ),
132
+ Nonce : i ,
133
+ GasPrice : big .NewInt (11111 ),
134
+ Gas : 1111 ,
135
+ To : & to ,
136
+ Value : big .NewInt (111 ),
137
+ Data : []byte {0x11 , 0x11 , 0x11 },
138
+ })
98
139
}
140
+ txs = append (txs , tx )
141
+ block = types .NewBlock (& types.Header {Number : big .NewInt (int64 (i ))}, []* types.Transaction {tx }, nil , nil , newHasher ())
99
142
WriteBlock (chainDb , block )
100
143
WriteCanonicalHash (chainDb , block .Hash (), block .NumberU64 ())
101
144
}
@@ -108,10 +151,10 @@ func TestIndexTransactions(t *testing.T) {
108
151
}
109
152
number := ReadTxLookupEntry (chainDb , txs [i - 1 ].Hash ())
110
153
if exist && number == nil {
111
- t .Fatalf ("Transaction indice missing" )
154
+ t .Fatalf ("Transaction index %d missing" , i )
112
155
}
113
156
if ! exist && number != nil {
114
- t .Fatalf ("Transaction indice is not deleted" )
157
+ t .Fatalf ("Transaction index %d is not deleted" , i )
115
158
}
116
159
}
117
160
number := ReadTxIndexTail (chainDb )
0 commit comments