osmosis-labs / test-tube

Test tube for cosmos-sdk chains integration test, written in Rust!
Apache License 2.0
54 stars 33 forks source link

ForceExecuteGovProposal #15

Open iboss-ptk opened 1 year ago

iboss-ptk commented 1 year ago

The idea here is to allow governance gated execution without voting in test.

Here is some implementation idea on go side:

// libosmosistesttube/main.go

//export ForceExecuteGovProposal
func ForceExecuteGovProposal(envId uint64, path, proposalTypeUrl, base64ProposalBytes string) *C.char {
    env := loadEnv(envId)

    // get router 
    govRouter := govkeeper.Keeper.Router(*env.App.GovKeeper)

    // unmarshal content from base64ProposalBytes and proposalTypeUrl
        // every proposal type implement `Content` interface
    // we might need to create a proposal type registry to fetch the correct type to unmarshal
    // but if you find a way to unmarshal without registry, that would be better
    content = ...
    err := govRouter.GetRoute(path)(env.Ctx, content)

    if err {
        return encodeErrToResultBytes(result.ExecuteError, err)
    }

    return encodeBytesResultBytes([]byte{})
}