'Represent a Vector<ManagedAddress> output in Mandos?
I am writing a mandos json test.
This is my method.
It returns a vector with addresses. I know with good probability this method works, I just need to test it, (I don't know how to write the test).
#[storage_mapper("match_id_to_address_map")]
#[view(getMatchIdToAddressMap)]
fn match_id_to_address_map(&self, match_id: u32) -> SingleValueMapper<Vec<ManagedAddress>>;
I want to write a test that makes sure it returns a vector with 2 addresses.
this is my mandos test:
{
"name": "new user with auto match",
"steps": [
// snipped for readability
{
"step": "scCall",
"txId": "9",
"tx": {
"from": "address:user_one",
"to": "sc:waiting_room",
"function": "getMatchIdToAddressMap",
"arguments": [
"1"
],
"gasLimit": "100000000",
"gasPrice": "1"
},
"expect": {
"out": [
"u64:0|address:owner|address:user_one" // <- !!! IDK what to do here !!!
],
"status": "",
"logs": [],
"gas": "*",
"refund": "*"
}
}
]
}
this is my error output:
Command line: ['/home/dan/elrondsdk/vmtools/mandos-test', '/home/dan/Elrond/SmartContracts/rooms/mandos']
Output: Scenario: deploy_and_wait.scen.json ... ok
Scenario: duplicate_wait.scen.json ... ok
Scenario: new_address_and_match.scen.json ... FAIL: result mismatch. Tx 9. Want: ["u64:0|address:owner|address:user_one"]. Have: [0x6f776e65725f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f757365725f6f6e655f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f]
Done. Passed: 2. Failed: 1. Skipped: 0.
ERROR: some tests failed
Solution 1:[1]
The actual decoded hex equals to
owner___________________________user_one________________________
We can see that the u64:0
isn't represented.
I don't have the answer, but I have a lead.
Look at the serialization documentation and replace u64:0
with the top level-encoding
The doc: https://docs.elrond.com/developers/developer-reference/elrond-serialization-format/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Fargerik |