From c1fd0f597b522f1fd2634ecf9ed4f2b0a999d521 Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Wed, 18 Oct 2023 15:22:53 +0000 Subject: [PATCH] add test for system.version() --- contract/vm_dummy/test_files/contract_system.lua | 7 +++++++ contract/vm_dummy/vm_dummy_test.go | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/contract/vm_dummy/test_files/contract_system.lua b/contract/vm_dummy/test_files/contract_system.lua index 88383efc7..246cfc63b 100644 --- a/contract/vm_dummy/test_files/contract_system.lua +++ b/contract/vm_dummy/test_files/contract_system.lua @@ -5,3 +5,10 @@ function testState() end abi.register(testState) + + +function get_version() + return system.version() +end + +abi.register_view(get_version) diff --git a/contract/vm_dummy/vm_dummy_test.go b/contract/vm_dummy/vm_dummy_test.go index db80c4bd1..b95b9c69f 100644 --- a/contract/vm_dummy/vm_dummy_test.go +++ b/contract/vm_dummy/vm_dummy_test.go @@ -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") + + } + } }