我正在写一个 mandos json 测试。
这是我的方法。
它返回一个带有地址的向量。我很可能知道这种方法有效,我只需要测试它,(我不知道如何编写测试)。
#[storage_mapper("match_id_to_address_map")]
#[view(getMatchIdToAddressMap)]
fn match_id_to_address_map(&self, match_id: u32) -> SingleValueMapper<Vec<ManagedAddress>>;
我想编写一个测试,确保它返回一个带有 2 个地址的向量。
这是我的 mandos 测试:
{
"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": "*"
}
}
]
}
这是我的错误输出:
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