Skip to content

Commit

Permalink
progrm_test: test keccak results
Browse files Browse the repository at this point in the history
  • Loading branch information
tsahee committed Apr 5, 2024
1 parent d1e1531 commit 3b412ee
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions system_tests/program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func testCalls(t *testing.T, jit bool) {

storeAddr := deployWasm(t, ctx, auth, l2client, rustFile("storage"))
keccakAddr := deployWasm(t, ctx, auth, l2client, rustFile("keccak"))
mockAddr, tx, _, err := mocksgen.DeployProgramTest(&auth, l2client)
mockAddr, tx, mockContract, err := mocksgen.DeployProgramTest(&auth, l2client)
ensure(tx, err)

colors.PrintGrey("multicall.wasm ", callsAddr)
Expand Down Expand Up @@ -464,6 +464,7 @@ func testCalls(t *testing.T, jit bool) {
args := argsForMulticall(vm.CALL, types.ArbDebugAddress, nil, pack(customRevert(uint64(32))))
spider := ": error Custom(32, This spider family wards off bugs: /\\oo/\\ //\\(oo)//\\ /\\oo/\\, true)"
expectFailure(callsAddr, args, spider)
spiderHash := crypto.Keccak256([]byte(spider))

colors.PrintBlue("Checking non-consensus revert data (Rust => precompile)")
args = argsForMulticall(vm.CALL, types.ArbDebugAddress, nil, pack(legacyError()))
Expand All @@ -473,7 +474,17 @@ func testCalls(t *testing.T, jit bool) {
rustArgs := append([]byte{0x01}, []byte(spider)...)
mockArgs := argsForMulticall(vm.CALL, mockAddr, nil, pack(callKeccak(keccakAddr, rustArgs)))
tx = l2info.PrepareTxTo("Owner", &callsAddr, 1e9, nil, mockArgs)
ensure(tx, l2client.SendTransaction(ctx, tx))
receipt := ensure(tx, l2client.SendTransaction(ctx, tx))
if len(receipt.Logs) != 1 {
Fatal(t, "expected 1 log got", len(receipt.Logs))
}
event, err := mockContract.ParseHash(*receipt.Logs[0])
if err != nil {
Fatal(t, err)
}
if bytes.Compare(event.Result[:], spiderHash) != 0 {

Check failure on line 485 in system_tests/program_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

S1004: should use !bytes.Equal(event.Result[:], spiderHash) instead (gosimple)

Check failure on line 485 in system_tests/program_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

S1004: should use !bytes.Equal(event.Result[:], spiderHash) instead (gosimple)

Check failure on line 485 in system_tests/program_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

S1004: should use !bytes.Equal(event.Result[:], spiderHash) instead (gosimple)

Check failure on line 485 in system_tests/program_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

S1004: should use !bytes.Equal(event.Result[:], spiderHash) instead (gosimple)
Fatal(t, "unexpected hash")
}

colors.PrintBlue("Checking call with value (Rust => EOA)")
eoa := testhelpers.RandomAddress()
Expand Down

0 comments on commit 3b412ee

Please sign in to comment.