@@ -47,41 +47,39 @@ func TestMain(m *testing.M) {
4747 goleak .VerifyTestMain (m , goleak .IgnoreCurrent ())
4848}
4949
50- type reverser struct {
50+ type concat struct {
5151 headerExtra []byte
5252 addr common.Address
5353 stateKey common.Hash
5454 gas uint64
5555}
5656
57- func (r * reverser ) BeforeBlock (h * types.Header ) {
58- r .headerExtra = slices .Clone (h .Extra )
57+ func (c * concat ) BeforeBlock (h * types.Header ) {
58+ c .headerExtra = slices .Clone (h .Extra )
5959}
6060
61- func (r * reverser ) Gas (tx * types.Transaction ) (uint64 , bool ) {
62- if to := tx .To (); to == nil || * to != r .addr {
63- return 0 , false
61+ func (c * concat ) Gas (tx * types.Transaction ) (uint64 , bool ) {
62+ if to := tx .To (); to != nil && * to == c .addr {
63+ return c . gas , true
6464 }
65- return r . gas , true
65+ return 0 , false
6666}
6767
68- func reverserOutput (txData []byte , state common.Hash , extra []byte ) []byte {
69- out := slices .Concat (txData , state [:], extra )
70- slices .Reverse (out )
71- return out
68+ func concatOutput (txData []byte , state common.Hash , extra []byte ) []byte {
69+ return slices .Concat (txData , state [:], extra )
7270}
7371
74- func (r * reverser ) Process (sdb libevm.StateReader , i int , tx * types.Transaction ) []byte {
75- return reverserOutput (
72+ func (c * concat ) Process (sdb libevm.StateReader , i int , tx * types.Transaction ) []byte {
73+ return concatOutput (
7674 tx .Data (),
77- sdb .GetTransientState (r .addr , r .stateKey ),
78- r .headerExtra ,
75+ sdb .GetTransientState (c .addr , c .stateKey ),
76+ c .headerExtra ,
7977 )
8078}
8179
8280func TestProcessor (t * testing.T ) {
83- handler := & reverser {
84- addr : common.Address {'r ' , 'e ' , 'v ' , 'e ' , 'r ' , 's' , 'e ' },
81+ handler := & concat {
82+ addr : common.Address {'c ' , 'o ' , 'n ' , 'c ' , 'a ' , 't ' },
8583 stateKey : common.Hash {'k' , 'e' , 'y' },
8684 gas : 1e6 ,
8785 }
@@ -164,7 +162,7 @@ func TestProcessor(t *testing.T) {
164162
165163 data := binary .BigEndian .AppendUint64 (nil , uint64 (i ))
166164 gas , err := intrinsicGas (data , types.AccessList {}, & handler .addr , & rules )
167- require .NoError (t , err , "core.IntrinsicGas(%#x, nil, false, true, true, true )" , data )
165+ require .NoError (t , err , "core.IntrinsicGas(%#x, nil, false, ... )" , data )
168166
169167 txs [i ] = types .NewTx (& types.LegacyTx {
170168 To : & to ,
@@ -183,7 +181,7 @@ func TestProcessor(t *testing.T) {
183181
184182 var want []byte
185183 if wantOK {
186- want = reverserOutput (tx .Data (), stateVal , extra )
184+ want = concatOutput (tx .Data (), stateVal , extra )
187185 }
188186
189187 got , gotOK := p .Result (i )
@@ -210,8 +208,8 @@ func (h *vmHooks) PreprocessingGasCharge(tx common.Hash) (uint64, error) {
210208
211209func TestIntegration (t * testing.T ) {
212210 const handlerGas = 500
213- handler := & reverser {
214- addr : common.Address {'r ' , 'e ' , 'v ' , 'e ' , 'r ' , 's' , 'e ' },
211+ handler := & concat {
212+ addr : common.Address {'c ' , 'o ' , 'n ' , 'c ' , 'a ' , 't ' },
215213 gas : handlerGas ,
216214 }
217215 sut := New (handler , 8 )
@@ -277,7 +275,7 @@ func TestIntegration(t *testing.T) {
277275 data := []byte ("hello, world" )
278276
279277 gas , err := intrinsicGas (data , types.AccessList {}, & addr , & rules )
280- require .NoError (t , err , "core.IntrinsicGas(%#x, nil, false, false, false, false )" , data )
278+ require .NoError (t , err , "core.IntrinsicGas(%#x, nil, false, ... )" , data )
281279 if addr == handler .addr {
282280 gas += handlerGas
283281 }
@@ -300,7 +298,7 @@ func TestIntegration(t *testing.T) {
300298 wantR .Logs = []* types.Log {{
301299 TxHash : tx .Hash (),
302300 TxIndex : ui ,
303- Data : reverserOutput (data , common.Hash {}, nil ),
301+ Data : concatOutput (data , common.Hash {}, nil ),
304302 }}
305303 }
306304 want = append (want , wantR )
0 commit comments