From db7a4baeaedc7e9af509419066e627750204f091 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 24 Jan 2022 13:15:36 +0100 Subject: [PATCH] Add tests for Rest client --- x/wasm/client/proposal_handler_test.go | 70 ++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/x/wasm/client/proposal_handler_test.go b/x/wasm/client/proposal_handler_test.go index f433122dc8..3e82c62e07 100644 --- a/x/wasm/client/proposal_handler_test.go +++ b/x/wasm/client/proposal_handler_test.go @@ -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{