* Update x/gov to use Any * Fixes * Remove MsgSubmitProposalLegacy * Update CHANGELOG.md * Add RegisterInterfaces for x/distribution, x/params, & x/upgrade * Fix query JSON issue * Fix gov tests * Revert custom Any Equals * Re-remove types * Rename receivers * Fix imports in gov * Sort imports * Make amino JSON signing work with Any * Run proto-gen * Create full amino wrapper * Fix errors * Fixes * Fix tests * Test fixes * Fix tests * Linting * Update ADR 019 and CHANGELOG * Updated ADR 019 * Extract Marshal/UnmarshalProposal * fix error * lint * linting * linting * Update client/keys/parse.go Co-authored-by: Marko <marbar3778@yahoo.com> * linting * Update docs/architecture/adr-019-protobuf-state-encoding.md Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> * Update docs/architecture/adr-019-protobuf-state-encoding.md Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> * Address review feedback * Add godocs * Fix errors * fix errors * revert file * Address review feedback * Address review feedback * Stacktrace debug flag * Fix tests * Address review feedback Co-authored-by: sahith-narahari <sahithnarahari@gmail.com> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package cli
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/spf13/viper"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/tests"
|
|
)
|
|
|
|
func TestGetBroadcastCommand_OfflineFlag(t *testing.T) {
|
|
cdc := codec.New()
|
|
cmd := GetBroadcastCommand(cdc)
|
|
|
|
viper.Set(flags.FlagOffline, true)
|
|
|
|
err := cmd.RunE(nil, []string{})
|
|
require.EqualError(t, err, "cannot broadcast tx during offline mode")
|
|
}
|
|
|
|
func TestGetBroadcastCommand_WithoutOfflineFlag(t *testing.T) {
|
|
cdc := codec.New()
|
|
cmd := GetBroadcastCommand(cdc)
|
|
|
|
viper.Set(flags.FlagOffline, false)
|
|
|
|
testDir, cleanFunc := tests.NewTestCaseDir(t)
|
|
t.Cleanup(cleanFunc)
|
|
|
|
// Create new file with tx
|
|
txContents := []byte("{\"type\":\"cosmos-sdk/StdTx\",\"value\":{\"msg\":[{\"type\":\"cosmos-sdk/MsgSend\",\"value\":{\"from_address\":\"cosmos1cxlt8kznps92fwu3j6npahx4mjfutydyene2qw\",\"to_address\":\"cosmos1wc8mpr8m3sy3ap3j7fsgqfzx36um05pystems4\",\"amount\":[{\"denom\":\"stake\",\"amount\":\"10000\"}]}}],\"fee\":{\"amount\":[],\"gas\":\"200000\"},\"signatures\":null,\"memo\":\"\"}}")
|
|
txFileName := filepath.Join(testDir, "tx.json")
|
|
err := ioutil.WriteFile(txFileName, txContents, 0644)
|
|
require.NoError(t, err)
|
|
|
|
err = cmd.RunE(cmd, []string{txFileName})
|
|
|
|
// We test it tries to broadcast but we set unsupported tx to get the error.
|
|
require.EqualError(t, err, "unsupported return type ; supported types: sync, async, block")
|
|
}
|