Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
pivilartisant committed Dec 6, 2024
1 parent ae04d7a commit a94b280
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
7 changes: 5 additions & 2 deletions api/test/robot_tests/cmd/cmd.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Documentation This is a test suite for Massa Station /cmd endpoints.
Library RequestsLibrary
Library Collections
Library BuiltIn
Library ../libs/encode_base64.py
Resource keywords.resource
Resource ../keywords.resource
Resource ../variables.resource
Expand All @@ -24,9 +26,10 @@ POST /cmd/read-only/executesc
Should Contain string(${response.json()}) TestSC is deployed at

POST a Smart Contract
${smartContractB64}= Encode File To Base64 ${CURDIR}/../../testSC/build/testSC.wasm
${data}= Create Dictionary
... nickname=${WALLET_NICKNAME}
... smartContract=${SMART_CONTRACT_BYTECODE}
... smartContract=${smartContractB64}
... maxCoins=3000000000000
... coins=8500000
... fee=10000000
Expand All @@ -37,7 +40,7 @@ POST a Smart Contract
Should Be Equal As Integers ${response.status_code} ${STATUS_OK} # Assert the status code is 200 OK
Should Contain ${response.json()['firstEvent']['data']} TestSC Constructor called

${sc_address}= Get SC address ${response.json()['firstEvent']['address']}
${sc_address}= Set Variable ${response.json()['firstEvent']['address']}
Set Global Variable ${DEPLOYED_SC_ADDR} ${sc_address}

POST /cmd/read-only/callsc
Expand Down
10 changes: 6 additions & 4 deletions api/test/robot_tests/event_manager/keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Documentation Keywords specific to event manager test suite
Library RequestsLibrary
Library ../libs/encode_base64.py
Resource ../keywords.resource


Expand All @@ -12,20 +13,21 @@ Suite Setup
Deploy testSC

Deploy testSC
${smartContractB64}= Encode File To Base64 ${CURDIR}/../../testSC/build/testSC.wasm
${data}= Create Dictionary
... nickname=${WALLET_NICKNAME}
... smartContract=${SMART_CONTRACT_BYTECODE}
... smartContract=${smartContractB64}
... maxCoins=3000000000000
... coins=18500000000
... fee=1000000
... coins=8500000
... fee=10000000
${headers}= Create Dictionary Content-Type=application/json
${response}= POST ${API_URL}/cmd/deploySC json=${data} headers=${headers} expected_status=any
Log To Console json response: ${response.json()} # Print the response content to the test log for debugging

Should Be Equal As Integers ${response.status_code} ${STATUS_OK} # Assert the status code is 200 OK
Should Contain ${response.json()['firstEvent']['data']} TestSC Constructor called

${sc_address}= Get SC address ${response.json()['firstEvent']['address']}
${sc_address}= Set Variable ${response.json()['firstEvent']['address']}
Set Global Variable ${DEPLOYED_SC_ADDR} ${sc_address}

Get Wallet Address
Expand Down
6 changes: 0 additions & 6 deletions api/test/robot_tests/keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ String To Arg
${byteArray}= ArgLibrary.String To Arg ${string}
RETURN ${byteArray}

Get SC address
[Documentation] Get the address of the SC from a string containing the address after ':' (colon)
[Arguments] ${string}
${words}= Split String ${string} :
${sc_address}= Get From List ${words} 0
RETURN ${sc_address}

Switch To Buildnet
${response}= POST
Expand Down
5 changes: 5 additions & 0 deletions api/test/robot_tests/libs/encode_base64.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import base64

def encode_file_to_base64(filepath):
with open(filepath, "rb") as f:
return base64.b64encode(f.read()).decode('utf-8')

0 comments on commit a94b280

Please sign in to comment.