Skip to content

Commit

Permalink
add test for system.version()
Browse files Browse the repository at this point in the history
  • Loading branch information
kroggen committed Oct 18, 2023
1 parent c27787a commit c1fd0f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions contract/vm_dummy/test_files/contract_system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ function testState()
end

abi.register(testState)


function get_version()
return system.version()
end

abi.register_view(get_version)
12 changes: 12 additions & 0 deletions contract/vm_dummy/vm_dummy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,18 @@ func TestContractSystem(t *testing.T) {
exRv := fmt.Sprintf(`["%s","6FbDRScGruVdATaNWzD51xJkTfYCVwxSZDb7gzqCLzwf","AmhNNBNY7XFk4p5ym4CJf8nTcRTEHjWzAeXJfhP71244CjBCAQU3",%d,3,999]`, StrToAddress("user1"), bc.cBlock.Header.Timestamp/1e9)
assert.Equal(t, exRv, receipt.GetRet(), "receipt ret error")

if version >= 4 {

tx = NewLuaTxCall("user1", "system", 0, `{"Name":"get_version", "Args":[]}`)
err = bc.ConnectBlock(tx)
require.NoErrorf(t, err, "failed to call tx")

receipt = bc.GetReceipt(tx.Hash())
expected := fmt.Sprintf(`%d`, version)
assert.Equal(t, expected, receipt.GetRet(), "receipt ret error")

}

}
}

Expand Down

0 comments on commit c1fd0f5

Please sign in to comment.