Skip to content

Commit a94888a

Browse files
committed
refactor: tests use raw addresses as semantic when appropriate
1 parent 10289ae commit a94888a

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

core/vm/contracts.libevm_test.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ func TestNewStatefulPrecompile(t *testing.T) {
217217
state.SetBalance(caller, new(uint256.Int).Not(uint256.NewInt(0)))
218218
evm.Origin = eoa
219219

220-
// By definition, the raw caller and self are the same, regardless of the
221-
// incoming call type.
222-
rawAddresses := &libevm.CallerAndSelf{
220+
// By definition, the raw caller and self are the same for every test case,
221+
// regardless of the incoming call type.
222+
rawAddresses := libevm.CallerAndSelf{
223223
Caller: caller,
224224
Self: precompile,
225225
}
@@ -240,12 +240,9 @@ func TestNewStatefulPrecompile(t *testing.T) {
240240
return evm.Call(callerContract, precompile, input, gasLimit, transferValue)
241241
},
242242
wantAddresses: &libevm.AddressContext{
243-
Origin: eoa,
244-
EVMSemantic: libevm.CallerAndSelf{
245-
Caller: caller,
246-
Self: precompile,
247-
},
248-
Raw: rawAddresses,
243+
Origin: eoa,
244+
EVMSemantic: rawAddresses,
245+
Raw: &rawAddresses,
249246
},
250247
wantReadOnly: false,
251248
wantTransferValue: transferValue,
@@ -262,7 +259,7 @@ func TestNewStatefulPrecompile(t *testing.T) {
262259
Caller: caller,
263260
Self: caller,
264261
},
265-
Raw: rawAddresses,
262+
Raw: &rawAddresses,
266263
},
267264
wantReadOnly: false,
268265
wantTransferValue: transferValue,
@@ -279,7 +276,7 @@ func TestNewStatefulPrecompile(t *testing.T) {
279276
Caller: eoa, // inherited from caller
280277
Self: caller,
281278
},
282-
Raw: rawAddresses,
279+
Raw: &rawAddresses,
283280
},
284281
wantReadOnly: false,
285282
wantTransferValue: uint256.NewInt(0),
@@ -291,12 +288,9 @@ func TestNewStatefulPrecompile(t *testing.T) {
291288
return evm.StaticCall(callerContract, precompile, input, gasLimit)
292289
},
293290
wantAddresses: &libevm.AddressContext{
294-
Origin: eoa,
295-
EVMSemantic: libevm.CallerAndSelf{
296-
Caller: caller,
297-
Self: precompile,
298-
},
299-
Raw: rawAddresses,
291+
Origin: eoa,
292+
EVMSemantic: rawAddresses,
293+
Raw: &rawAddresses,
300294
},
301295
wantReadOnly: true,
302296
wantTransferValue: uint256.NewInt(0),
@@ -824,7 +818,7 @@ func TestPrecompileMakeCall(t *testing.T) {
824818

825819
for _, tt := range tests {
826820
t.Run(tt.incomingCallType.String(), func(t *testing.T) {
827-
// From the perspective of `dest` after a CALL.
821+
// From the perspective of `dest` after a CALL from `sut`.
828822
tt.want.Addresses.Raw = &tt.want.Addresses.EVMSemantic
829823

830824
t.Logf("calldata = %q", tt.eoaTxCallData)

0 commit comments

Comments
 (0)