Add tests for Rest client

This commit is contained in:
Ethan Frey
2022-01-24 13:15:36 +01:00
parent fb1240c29a
commit 8a9771e8f6

View File

@@ -183,6 +183,76 @@ func TestGovRestHandlers(t *testing.T) {
},
expCode: http.StatusOK,
},
"execute contract": {
srcPath: "/gov/proposals/wasm_execute",
srcBody: dict{
"title": "Test Proposal",
"description": "My proposal",
"type": "migrate",
"contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr",
"msg": dict{"foo": "bar"},
"run_as": "cosmos100dejzacpanrldpjjwksjm62shqhyss44jf5xz",
"deposit": []dict{{"denom": "ustake", "amount": "10"}},
"proposer": "cosmos1ve557a5g9yw2g2z57js3pdmcvd5my6g8ze20np",
"base_req": aBaseReq,
},
expCode: http.StatusOK,
},
"execute contract fails with no run_as": {
srcPath: "/gov/proposals/wasm_execute",
srcBody: dict{
"title": "Test Proposal",
"description": "My proposal",
"type": "migrate",
"contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr",
"msg": dict{"foo": "bar"},
"deposit": []dict{{"denom": "ustake", "amount": "10"}},
"proposer": "cosmos1ve557a5g9yw2g2z57js3pdmcvd5my6g8ze20np",
"base_req": aBaseReq,
},
expCode: http.StatusBadRequest,
},
"execute contract fails with no message": {
srcPath: "/gov/proposals/wasm_execute",
srcBody: dict{
"title": "Test Proposal",
"description": "My proposal",
"type": "migrate",
"contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr",
"run_as": "cosmos100dejzacpanrldpjjwksjm62shqhyss44jf5xz",
"deposit": []dict{{"denom": "ustake", "amount": "10"}},
"proposer": "cosmos1ve557a5g9yw2g2z57js3pdmcvd5my6g8ze20np",
"base_req": aBaseReq,
},
expCode: http.StatusBadRequest,
},
"sudo contract": {
srcPath: "/gov/proposals/wasm_sudo",
srcBody: dict{
"title": "Test Proposal",
"description": "My proposal",
"type": "migrate",
"contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr",
"msg": dict{"foo": "bar"},
"deposit": []dict{{"denom": "ustake", "amount": "10"}},
"proposer": "cosmos1ve557a5g9yw2g2z57js3pdmcvd5my6g8ze20np",
"base_req": aBaseReq,
},
expCode: http.StatusOK,
},
"sudo contract fails with no message": {
srcPath: "/gov/proposals/wasm_sudo",
srcBody: dict{
"title": "Test Proposal",
"description": "My proposal",
"type": "migrate",
"contract": "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr",
"deposit": []dict{{"denom": "ustake", "amount": "10"}},
"proposer": "cosmos1ve557a5g9yw2g2z57js3pdmcvd5my6g8ze20np",
"base_req": aBaseReq,
},
expCode: http.StatusBadRequest,
},
"update contract admin": {
srcPath: "/gov/proposals/wasm_update_admin",
srcBody: dict{