Skip to content

Commit

Permalink
fix encode
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Jul 18, 2024
1 parent 456b40e commit d5bbb72
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
20 changes: 19 additions & 1 deletion app/params/proto.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
package params

import (
"cosmossdk.io/x/tx/signing"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
gogoproto "github.com/cosmos/gogoproto/proto"
)

// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration.
func MakeEncodingConfig() EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
signingOptions := signing.Options{
AddressCodec: address.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(),
},
ValidatorAddressCodec: address.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(),
},
}
interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
ProtoFiles: gogoproto.HybridResolver,
SigningOptions: signingOptions,
})
if err != nil {
panic(err)
}
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)

Expand Down
1 change: 1 addition & 0 deletions integration_tests/configs/genesis.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
gov: {
params: {
expedited_voting_period: '1s',
voting_period: '10s',
max_deposit_period: '10s',
min_deposit: [
Expand Down
12 changes: 8 additions & 4 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,18 @@ def module_address(name):
return bech32.bech32_encode("cro", bech32.convertbits(data, 8, 5))


def get_sync_info(s):
return s.get("SyncInfo") or s.get("sync_info")


def wait_for_block(cli, height, timeout=240):
for i in range(timeout * 2):
try:
status = cli.status()
except AssertionError as e:
print(f"get sync status failed: {e}", file=sys.stderr)
else:
current_height = int(status["SyncInfo"]["latest_block_height"])
current_height = int(get_sync_info(status)["latest_block_height"])
if current_height >= height:
break
print("current block height", current_height)
Expand All @@ -104,18 +108,18 @@ def wait_for_block(cli, height, timeout=240):


def wait_for_new_blocks(cli, n, sleep=0.5):
begin_height = int((cli.status())["SyncInfo"]["latest_block_height"])
begin_height = int(get_sync_info((cli.status()))["latest_block_height"])
while True:
time.sleep(sleep)
cur_height = int((cli.status())["SyncInfo"]["latest_block_height"])
cur_height = int(get_sync_info((cli.status()))["latest_block_height"])
if cur_height - begin_height >= n:
break


def wait_for_block_time(cli, t):
print("wait for block time", t)
while True:
now = isoparse((cli.status())["SyncInfo"]["latest_block_time"])
now = isoparse(get_sync_info(cli.status())["latest_block_time"])
print("block time now:", now)
if now >= t:
break
Expand Down

0 comments on commit d5bbb72

Please sign in to comment.