Skip to content

Commit

Permalink
multisig: code fixes + unit test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CostinCarabas committed Nov 21, 2024
1 parent 46c4ab2 commit 2a63507
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"nonce": "*",
"balance": "*",
"storage": {
"str:action_data.item|u32:1": {
"str:actionData.item|u32:1": {
"1-action_type": "u8:1",
"2-batch_id": "u64:1",
"3-tx_batch_status_len": "u32:2",
Expand All @@ -51,7 +51,6 @@
"+": {}
}
},

{
"step": "scCall",
"txId": "second-relayer-sign",
Expand Down Expand Up @@ -257,4 +256,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"nonce": "*",
"balance": "*",
"storage": {
"str:action_data.item|u32:1": {
"str:actionData.item|u32:1": {
"1-action_type": "u8:1",
"2-batch_id": "u64:1",
"3-tx_batch_status_len": "u32:2",
Expand Down Expand Up @@ -286,4 +286,4 @@
}
}
]
}
}
44 changes: 22 additions & 22 deletions multisig/scenarios/setup.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@
"str:tokenTicker|nested:str:GWEI": "str:GWEI",
"str:tokenTicker|nested:str:WEGLD-123456": "str:WEGLD",
"str:tokenTicker|nested:str:ETH-123456": "str:ETH",
"str:tokenWhitelist.index|nested:str:WEGLD-123456": "1",
"str:tokenWhitelist.item|u32:1": "str:WEGLD-123456",
"str:tokenWhitelist.index|nested:str:ETH-123456": "2",
"str:tokenWhitelist.item|u32:2": "str:ETH-123456",
"str:tokenWhitelist.len": "2",
"str:mintBalances|nested:str:WEGLD-123456": "500,000,000,000",
"str:mintBalances|nested:str:ETH-123456": "500,000,000,000"
},
Expand All @@ -106,6 +101,11 @@
"balance": "1000",
"storage": {}
},
"address:relayer3": {
"nonce": "0",
"balance": "1000",
"storage": {}
},
"address:user": {
"nonce": "0",
"balance": "0",
Expand Down Expand Up @@ -170,12 +170,12 @@
"str:proxyAddress": "sc:bridge_proxy",
"str:bridgedTokensWrapperAddress": "sc:bridged_tokens_wrapper",
"str:feeEstimatorAddress": "sc:price_aggregator",
"str:num_board_members": "2",
"str:numBoardMembers": "2",
"str:quorum": "2",
"str:requiredStakeAmount": "1000",
"str:slashAmount": "500",
"str:user_role|u32:1": "1",
"str:user_role|u32:2": "1",
"str:userRole|u32:1": "1",
"str:userRole|u32:2": "1",
"str:user_address_to_id|address:relayer1": "1",
"str:user_address_to_id|address:relayer2": "2",
"str:user_count": "2",
Expand Down Expand Up @@ -287,20 +287,6 @@
]
}
},
{
"step": "scQuery",
"txId": "get-all-known-tokens",
"tx": {
"to": "sc:esdt_safe",
"function": "getAllKnownTokens"
},
"expect": {
"out": [
"str:WEGLD-123456",
"str:ETH-123456"
]
}
},
{
"step": "scCall",
"txId": "unpause multisig",
Expand Down Expand Up @@ -375,6 +361,20 @@
"gas": "*",
"refund": "*"
}
},
{
"step": "scQuery",
"txId": "get-all-known-tokens",
"tx": {
"to": "sc:esdt_safe",
"function": "getAllKnownTokens"
},
"expect": {
"out": [
"str:WEGLD-123456",
"str:ETH-123456"
]
}
}
]
}
116 changes: 107 additions & 9 deletions multisig/scenarios/unstake.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,67 @@
"gasLimit": "35,000,000",
"gasPrice": "0"
},
"expect": {
"status": "4",
"message": "str:Quorum size not appropriate",
"out": [],
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"txId": "third-relayer-stake",
"tx": {
"from": "address:relayer3",
"to": "sc:multisig",
"value": "1000",
"function": "stake",
"arguments": [],
"gasLimit": "35,000,000",
"gasPrice": "0"
},
"expect": {
"status": "4",
"message": "str:Only board members can stake",
"out": [],
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"txId": "add-board-member",
"tx": {
"from": "address:owner",
"to": "sc:multisig",
"function": "addBoardMember",
"arguments": [
"address:relayer3"
],
"gasLimit": "35,000,000",
"gasPrice": "0"
},
"expect": {
"status": "0",
"message": "",
"out": [],
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"txId": "third-relayer-stake",
"tx": {
"from": "address:relayer3",
"to": "sc:multisig",
"value": "1,000",
"function": "stake",
"arguments": [],
"gasLimit": "35,000,000",
"gasPrice": "0"
},
"expect": {
"status": "0",
"message": "",
Expand All @@ -50,17 +111,52 @@
"refund": "*"
}
},
{
"step": "scQuery",
"txId": "getAllStakedRelayers - only one staked",
"tx": {
"to": "sc:multisig",
"function": "getAllStakedRelayers",
"arguments": []
},
"expect": {
"status": "0",
"message": "",
"out": [
"address:relayer1",
"address:relayer2",
"address:relayer3"
]
}
},
{
"step": "checkState",
"accounts": {
"address:relayer1": {
"nonce": "2",
"balance": "0",
"storage": {}
},
"address:relayer2": {
"nonce": "1",
"balance": "0",
"storage": {}
},
"address:relayer3": {
"nonce": "2",
"balance": "0",
"storage": {}
},
"sc:multisig": {
"nonce": "*",
"balance": "*",
"balance": "3000",
"storage": {
"str:quorum": "1",
"str:amountStaked|address:relayer1": "1000",
"str:amountStaked|address:relayer2": "1000",
"str:amountStaked|address:relayer3": "1000",
"+": ""
},
"code": "*"
"code": "file:../output/multisig.wasm"
},
"+": {}
}
Expand Down Expand Up @@ -92,11 +188,12 @@
"accounts": {
"sc:multisig": {
"nonce": "*",
"balance": "2000",
"balance": "3000",
"storage": {
"str:quorum": "1",
"str:user_role|u32:1": "1",
"str:quorum": "2",
"str:user_role|u32:1": "0",
"str:user_role|u32:2": "0",
"str:user_role|u32:3": "0",
"+": ""
},
"code": "*"
Expand Down Expand Up @@ -158,11 +255,12 @@
},
"sc:multisig": {
"nonce": "*",
"balance": "1000",
"balance": "2000",
"storage": {
"str:quorum": "1",
"str:user_role|u32:1": "1",
"str:quorum": "2",
"str:user_role|u32:1": "0",
"str:user_role|u32:2": "0",
"str:user_role|u32:3": "0",
"+": ""
},
"code": "*"
Expand Down
2 changes: 1 addition & 1 deletion multisig/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub trait SetupModule:
let total_users = self.user_mapper().get_user_count();
let mut board_member_with_valid_stake: usize = 0;

for user_id in 0..total_users {
for user_id in 1..total_users + 1 {
let user_role = self.user_id_to_role(user_id).get();

if user_role.is_board_member() {
Expand Down

0 comments on commit 2a63507

Please sign in to comment.