Skip to content

Commit

Permalink
Adjust answer-locals.wat and .wasm again
Browse files Browse the repository at this point in the history
  • Loading branch information
camilbancioiu committed Oct 5, 2023
1 parent 6ceb34b commit 9fedfca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions test/contracts/answer-locals/answer-locals.wat
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
(type (;0;) (func (param i64)))
(type (;1;) (func))
(import "env" "int64finish" (func (;0;) (type 0)))
(func (;1;) (type 1)
(local i64 i64 i64 i64 i64)
(func (;1;) (type 1))
(func (;2;) (type 1)
(local i64 i64 i64 i64)
i64.const 42
call 0)
(table (;0;) 1 1 funcref)
(memory (;0;) 2)
(global (;0;) (mut i32) (i32.const 66560))
(export "memory" (memory 0))
(export "init" (func 1)))
(export "init" (func 1))
(export "answer" (func 2)))
Binary file modified test/contracts/answer-locals/output/answer-locals.wasm
Binary file not shown.
9 changes: 5 additions & 4 deletions vmhost/hosttest/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3687,8 +3687,9 @@ func TestExecution_Mocked_OnSameFollowedByOnDest(t *testing.T) {
// number of i64 locals it instantiates
func makeBytecodeWithLocals(numLocals uint64) []byte {
originalCode := test.GetTestSCCode("answer-locals", "../../")
firstSlice := originalCode[:0x59]
secondSlice := originalCode[0x5A:]

firstSlice := originalCode[:0x66]
secondSlice := originalCode[0x67:]

encodedNumLocals := vmhost.U64ToLEB128(numLocals)
extraBytes := len(encodedNumLocals) - 1
Expand All @@ -3698,8 +3699,8 @@ func makeBytecodeWithLocals(numLocals uint64) []byte {
result = append(result, encodedNumLocals...)
result = append(result, secondSlice...)

result[0x55] = byte(int(result[0x55]) + extraBytes)
result[0x57] = byte(int(result[0x57]) + extraBytes)
result[0x5F] = byte(int(result[0x5F]) + extraBytes)
result[0x64] = byte(int(result[0x64]) + extraBytes)

return result
}
Expand Down

0 comments on commit 9fedfca

Please sign in to comment.