Skip to content

Commit

Permalink
Addressing comments to v1 vs v2 (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
vertex451 authored Jul 28, 2023
1 parent 4ce0be7 commit 7eee4ac
Show file tree
Hide file tree
Showing 25 changed files with 135 additions and 167 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ provide the correct `node` and `chain-id` flags to the cli command.
As an example here is a command to connect to the testnet to get the status:

```
$ cored status --chain-id=coreum-devnet-1 --node=https://full-node.testnet-1.coreum.dev:26657
$ cored status --chain-id=coreum-testnet-1 --node=https://full-node.testnet-1.coreum.dev:26657
```
It should also be mentioned that for development purposes testnet is more stable than devnet.

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func (c ChainContext) GenAccount() sdk.AccAddress {
return c.ImportMnemonic(mnemonic)
}

// ConvertToBech32Address converts the address to bech32 address string.
func (c ChainContext) ConvertToBech32Address(address sdk.AccAddress) string {
// MustConvertToBech32Address converts the address to bech32 address string.
func (c ChainContext) MustConvertToBech32Address(address sdk.AccAddress) string {
bech32Address, err := bech32.ConvertAndEncode(c.ChainSettings.AddressPrefix, address)
if err != nil {
panic(err)
Expand Down Expand Up @@ -155,7 +155,7 @@ func (c ChainContext) SignAndBroadcastMultisigTx(
return nil, errors.WithStack(err)
}
if keyInfo.GetAlgo() != hd.MultiType {
return nil, errors.Errorf("%s is not a multisig account", c.ConvertToBech32Address(keyInfo.GetAddress()))
return nil, errors.Errorf("%s is not a multisig account", c.MustConvertToBech32Address(keyInfo.GetAddress()))
}
multisigPubKey, ok := keyInfo.GetPubKey().(*sdkmultisig.LegacyAminoPubKey)
if !ok {
Expand Down
12 changes: 6 additions & 6 deletions integration-tests/chain_ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func (c ChainContext) ExecuteIBCTransfer(
) (*sdk.TxResponse, error) {
t.Helper()

sender := c.ConvertToBech32Address(senderAddress)
receiver := recipientChainContext.ConvertToBech32Address(recipientAddress)
sender := c.MustConvertToBech32Address(senderAddress)
receiver := recipientChainContext.MustConvertToBech32Address(recipientAddress)
t.Logf("Sending IBC transfer sender: %s, receiver: %s, amount: %s.", sender, receiver, coin.String())

recipientChannelID := c.AwaitForIBCChannelID(ctx, t, ibctransfertypes.PortID, recipientChainContext.ChainSettings.ChainID)
Expand Down Expand Up @@ -82,8 +82,8 @@ func (c ChainContext) ExecuteTimingOutIBCTransfer(
) (*sdk.TxResponse, error) {
t.Helper()

sender := c.ConvertToBech32Address(senderAddress)
receiver := recipientChainContext.ConvertToBech32Address(recipientAddress)
sender := c.MustConvertToBech32Address(senderAddress)
receiver := recipientChainContext.MustConvertToBech32Address(recipientAddress)
t.Logf("Sending timing out IBC transfer from %s, to %s, %s.", sender, receiver, coin.String())

recipientChannelID := c.AwaitForIBCChannelID(ctx, t, ibctransfertypes.PortID, recipientChainContext.ChainSettings.ChainID)
Expand Down Expand Up @@ -118,7 +118,7 @@ func (c ChainContext) AwaitForBalance(
) error {
t.Helper()

t.Logf("Waiting for account %s balance, expected amount: %s.", c.ConvertToBech32Address(address), expectedBalance.String())
t.Logf("Waiting for account %s balance, expected amount: %s.", c.MustConvertToBech32Address(address), expectedBalance.String())
bankClient := banktypes.NewQueryClient(c.ClientContext)
retryCtx, retryCancel := context.WithTimeout(ctx, 30*time.Second)
defer retryCancel()
Expand All @@ -128,7 +128,7 @@ func (c ChainContext) AwaitForBalance(

// We intentionally query all balances instead of single denom here to include this info inside error message.
balancesRes, err := bankClient.AllBalances(requestCtx, &banktypes.QueryAllBalancesRequest{
Address: c.ConvertToBech32Address(address),
Address: c.MustConvertToBech32Address(address),
})
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/chain_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (c ChainContext) BroadcastTxWithSigner(ctx context.Context, txf client.Fact
clientCtx := c.ClientContext.WithFromAddress(signerAddress)

// add account info
txf, err := addAccountInfoToTxFactory(ctx, clientCtx, txf, c.ConvertToBech32Address(signerAddress))
txf, err := addAccountInfoToTxFactory(ctx, clientCtx, txf, c.MustConvertToBech32Address(signerAddress))
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/coreum.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func (c CoreumChain) GasLimitByMsgs(msgs ...sdk.Msg) uint64 {
return totalGasRequired
}

// GasLimitByMultiSendMsgs calculates sum of gas limits required for message types passed and includes the FixedGas once.
// GasLimitForMultiMsgTx calculates sum of gas limits required for message types passed and includes the FixedGas once.
// It panics if unsupported message type specified.
func (c CoreumChain) GasLimitByMultiSendMsgs(msgs ...sdk.Msg) uint64 {
func (c CoreumChain) GasLimitForMultiMsgTx(msgs ...sdk.Msg) uint64 {
var totalGasRequired uint64
for _, msg := range msgs {
msgGas, exists := c.DeterministicGasConfig.GasRequiredByMessage(msg)
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ func (f Faucet) prepareMultiSendMessage(requests []fundingRequest) *banktypes.Ms
for _, a := range r.AccountsToFund {
sum = sum.Add(a.Amount)
msg.Outputs = append(msg.Outputs, banktypes.Output{
Address: f.chainCtx.ConvertToBech32Address(a.Address),
Address: f.chainCtx.MustConvertToBech32Address(a.Address),
Coins: sdk.NewCoins(a.Amount),
})
}
}
msg.Inputs = []banktypes.Input{{
Address: f.chainCtx.ConvertToBech32Address(f.chainCtx.ClientContext.FromAddress()),
Address: f.chainCtx.MustConvertToBech32Address(f.chainCtx.ClientContext.FromAddress()),
Coins: sum,
}}

Expand Down
64 changes: 32 additions & 32 deletions integration-tests/ibc/asset_ft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
gaiaRecipient1,
receiveCoinGaia,
map[string]sdk.Int{
coreumChain.ConvertToBech32Address(coreumIssuer): sendCoin.Amount.Neg(),
coreumChain.ConvertToBech32Address(coreumToGaiaEscrowAddress): sendCoin.Amount,
coreumChain.MustConvertToBech32Address(coreumIssuer): sendCoin.Amount.Neg(),
coreumChain.MustConvertToBech32Address(coreumToGaiaEscrowAddress): sendCoin.Amount,
},
map[string]sdk.Int{
gaiaChain.ConvertToBech32Address(gaiaRecipient1): sendCoin.Amount,
gaiaChain.MustConvertToBech32Address(gaiaRecipient1): sendCoin.Amount,
},
)

Expand All @@ -206,12 +206,12 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
gaiaRecipient2,
receiveCoinGaia,
map[string]sdk.Int{
coreumChain.ConvertToBech32Address(coreumSender): sendCoin.Amount.Add(sendCommissionAmount).Add(burntAmount).Neg(),
coreumChain.ConvertToBech32Address(coreumIssuer): sendCommissionAmount,
coreumChain.ConvertToBech32Address(coreumToGaiaEscrowAddress): sendCoin.Amount,
coreumChain.MustConvertToBech32Address(coreumSender): sendCoin.Amount.Add(sendCommissionAmount).Add(burntAmount).Neg(),
coreumChain.MustConvertToBech32Address(coreumIssuer): sendCommissionAmount,
coreumChain.MustConvertToBech32Address(coreumToGaiaEscrowAddress): sendCoin.Amount,
},
map[string]sdk.Int{
gaiaChain.ConvertToBech32Address(gaiaRecipient2): sendCoin.Amount,
gaiaChain.MustConvertToBech32Address(gaiaRecipient2): sendCoin.Amount,
},
)

Expand All @@ -227,11 +227,11 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
osmosisRecipient1,
receiveCoinOsmosis,
map[string]sdk.Int{
coreumChain.ConvertToBech32Address(coreumIssuer): sendCoin.Amount.Neg(),
coreumChain.ConvertToBech32Address(coreumToOsmosisEscrowAddress): sendCoin.Amount,
coreumChain.MustConvertToBech32Address(coreumIssuer): sendCoin.Amount.Neg(),
coreumChain.MustConvertToBech32Address(coreumToOsmosisEscrowAddress): sendCoin.Amount,
},
map[string]sdk.Int{
osmosisChain.ConvertToBech32Address(osmosisRecipient1): sendCoin.Amount,
osmosisChain.MustConvertToBech32Address(osmosisRecipient1): sendCoin.Amount,
},
)

Expand All @@ -246,12 +246,12 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
osmosisRecipient2,
receiveCoinOsmosis,
map[string]sdk.Int{
coreumChain.ConvertToBech32Address(coreumSender): sendCoin.Amount.Add(sendCommissionAmount).Add(burntAmount).Neg(),
coreumChain.ConvertToBech32Address(coreumIssuer): sendCommissionAmount,
coreumChain.ConvertToBech32Address(coreumToOsmosisEscrowAddress): sendCoin.Amount,
coreumChain.MustConvertToBech32Address(coreumSender): sendCoin.Amount.Add(sendCommissionAmount).Add(burntAmount).Neg(),
coreumChain.MustConvertToBech32Address(coreumIssuer): sendCommissionAmount,
coreumChain.MustConvertToBech32Address(coreumToOsmosisEscrowAddress): sendCoin.Amount,
},
map[string]sdk.Int{
osmosisChain.ConvertToBech32Address(osmosisRecipient2): sendCoin.Amount,
osmosisChain.MustConvertToBech32Address(osmosisRecipient2): sendCoin.Amount,
},
)

Expand All @@ -267,11 +267,11 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
coreumIssuer,
sendCoin,
map[string]sdk.Int{
gaiaChain.ConvertToBech32Address(gaiaRecipient1): sendCoin.Amount.Neg(),
gaiaChain.MustConvertToBech32Address(gaiaRecipient1): sendCoin.Amount.Neg(),
},
map[string]sdk.Int{
coreumChain.ConvertToBech32Address(coreumToGaiaEscrowAddress): sendCoin.Amount.Neg(),
coreumChain.ConvertToBech32Address(coreumIssuer): sendCoin.Amount,
coreumChain.MustConvertToBech32Address(coreumToGaiaEscrowAddress): sendCoin.Amount.Neg(),
coreumChain.MustConvertToBech32Address(coreumIssuer): sendCoin.Amount,
},
)

Expand All @@ -286,12 +286,12 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
coreumSender,
sendCoin,
map[string]sdk.Int{
gaiaChain.ConvertToBech32Address(gaiaRecipient2): sendCoin.Amount.Neg(),
gaiaChain.MustConvertToBech32Address(gaiaRecipient2): sendCoin.Amount.Neg(),
},
map[string]sdk.Int{
coreumChain.ConvertToBech32Address(coreumToGaiaEscrowAddress): sendCoin.Amount.Neg(),
coreumChain.ConvertToBech32Address(coreumSender): sendCoin.Amount,
coreumChain.ConvertToBech32Address(coreumIssuer): sdk.ZeroInt(),
coreumChain.MustConvertToBech32Address(coreumToGaiaEscrowAddress): sendCoin.Amount.Neg(),
coreumChain.MustConvertToBech32Address(coreumSender): sendCoin.Amount,
coreumChain.MustConvertToBech32Address(coreumIssuer): sdk.ZeroInt(),
},
)

Expand All @@ -307,11 +307,11 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
coreumIssuer,
sendCoin,
map[string]sdk.Int{
osmosisChain.ConvertToBech32Address(osmosisRecipient1): sendCoin.Amount.Neg(),
osmosisChain.MustConvertToBech32Address(osmosisRecipient1): sendCoin.Amount.Neg(),
},
map[string]sdk.Int{
coreumChain.ConvertToBech32Address(coreumToOsmosisEscrowAddress): sendCoin.Amount.Neg(),
coreumChain.ConvertToBech32Address(coreumIssuer): sendCoin.Amount,
coreumChain.MustConvertToBech32Address(coreumToOsmosisEscrowAddress): sendCoin.Amount.Neg(),
coreumChain.MustConvertToBech32Address(coreumIssuer): sendCoin.Amount,
},
)

Expand All @@ -326,12 +326,12 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
coreumSender,
sendCoin,
map[string]sdk.Int{
osmosisChain.ConvertToBech32Address(osmosisRecipient2): sendCoin.Amount.Neg(),
osmosisChain.MustConvertToBech32Address(osmosisRecipient2): sendCoin.Amount.Neg(),
},
map[string]sdk.Int{
coreumChain.ConvertToBech32Address(coreumToOsmosisEscrowAddress): sendCoin.Amount.Neg(),
coreumChain.ConvertToBech32Address(coreumSender): sendCoin.Amount,
coreumChain.ConvertToBech32Address(coreumIssuer): sdk.ZeroInt(),
coreumChain.MustConvertToBech32Address(coreumToOsmosisEscrowAddress): sendCoin.Amount.Neg(),
coreumChain.MustConvertToBech32Address(coreumSender): sendCoin.Amount,
coreumChain.MustConvertToBech32Address(coreumIssuer): sdk.ZeroInt(),
},
)
}
Expand Down Expand Up @@ -864,7 +864,7 @@ func TestIBCAssetFTTimedOutTransfer(t *testing.T) {
// funds should not be received on gaia
bankClient := banktypes.NewQueryClient(gaiaChain.ClientContext)
resp, err := bankClient.Balance(ctx, &banktypes.QueryBalanceRequest{
Address: gaiaChain.ConvertToBech32Address(gaiaRecipient),
Address: gaiaChain.MustConvertToBech32Address(gaiaRecipient),
Denom: convertToIBCDenom(gaiaToCoreumChannelID, sendToGaiaCoin.Denom),
})
requireT.NoError(err)
Expand Down Expand Up @@ -935,7 +935,7 @@ func TestIBCAssetFTRejectedTransfer(t *testing.T) {
ibcGaiaDenom := convertToIBCDenom(gaiaToCoreumChannelID, sendToGaiaCoin.Denom)
bankClient := banktypes.NewQueryClient(gaiaChain.ClientContext)
resp, err := bankClient.Balance(ctx, &banktypes.QueryBalanceRequest{
Address: gaiaChain.ConvertToBech32Address(moduleAddress),
Address: gaiaChain.MustConvertToBech32Address(moduleAddress),
Denom: ibcGaiaDenom,
})
requireT.NoError(err)
Expand All @@ -961,7 +961,7 @@ func TestIBCAssetFTRejectedTransfer(t *testing.T) {
// funds should not be received on coreum
bankClient = banktypes.NewQueryClient(coreumChain.ClientContext)
resp, err = bankClient.Balance(ctx, &banktypes.QueryBalanceRequest{
Address: coreumChain.ConvertToBech32Address(moduleAddress),
Address: coreumChain.MustConvertToBech32Address(moduleAddress),
Denom: sendToGaiaCoin.Denom,
})
requireT.NoError(err)
Expand Down Expand Up @@ -1287,7 +1287,7 @@ func ibcTransferAndAssertBalanceChanges(

dstBankClient := banktypes.NewQueryClient(dstChainCtx.ClientContext)
dstChainRecipientBalanceBefore, err := dstBankClient.Balance(ctx, &banktypes.QueryBalanceRequest{
Address: dstChainCtx.ConvertToBech32Address(dstChainRecipient),
Address: dstChainCtx.MustConvertToBech32Address(dstChainRecipient),
Denom: receiveCoin.Denom,
})
requireT.NoError(err)
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/ibc/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func TestTimedOutTransfer(t *testing.T) {
// funds should not be received on gaia
bankClient := banktypes.NewQueryClient(osmosisChain.ClientContext)
resp, err := bankClient.Balance(ctx, &banktypes.QueryBalanceRequest{
Address: osmosisChain.ConvertToBech32Address(gaiaRecipient),
Address: osmosisChain.MustConvertToBech32Address(gaiaRecipient),
Denom: convertToIBCDenom(osmosisToCoreumChannelID, sendToGaiaCoin.Denom),
})
requireT.NoError(err)
Expand Down Expand Up @@ -255,7 +255,7 @@ func TestRejectedTransfer(t *testing.T) {
ibcGaiaDenom := convertToIBCDenom(gaiaToCoreumChannelID, sendToGaiaCoin.Denom)
bankClient := banktypes.NewQueryClient(gaiaChain.ClientContext)
resp, err := bankClient.Balance(ctx, &banktypes.QueryBalanceRequest{
Address: gaiaChain.ConvertToBech32Address(moduleAddress),
Address: gaiaChain.MustConvertToBech32Address(moduleAddress),
Denom: ibcGaiaDenom,
})
requireT.NoError(err)
Expand All @@ -281,7 +281,7 @@ func TestRejectedTransfer(t *testing.T) {
// funds should not be received on coreum
bankClient = banktypes.NewQueryClient(coreumChain.ClientContext)
resp, err = bankClient.Balance(ctx, &banktypes.QueryBalanceRequest{
Address: coreumChain.ConvertToBech32Address(moduleAddress),
Address: coreumChain.MustConvertToBech32Address(moduleAddress),
Denom: sendToGaiaCoin.Denom,
})
requireT.NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ibc/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestIBCTransferFromSmartContract(t *testing.T) {
transferPayload, err := json.Marshal(map[ibcTransferMethod]ibcTransferRequest{
ibcTransferMethodTransfer: {
ChannelID: coreumToOsmosisChannelID,
ToAddress: osmosisChain.ConvertToBech32Address(osmosisRecipient),
ToAddress: osmosisChain.MustConvertToBech32Address(osmosisRecipient),
Amount: sendToOsmosisCoin,
Timeout: ibcTimeout{
Block: ibcTimeoutBlock{
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/modules/bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func TestBankSendDeterministicGasTwoBankSends(t *testing.T) {
Amount: sdk.NewInt(2000),
})

gasExpected := chain.GasLimitByMultiSendMsgs(&banktypes.MsgSend{}, &banktypes.MsgSend{})
gasExpected := chain.GasLimitForMultiMsgTx(&banktypes.MsgSend{}, &banktypes.MsgSend{})
clientCtx := chain.ChainContext.ClientContext.WithFromAddress(sender)
txf := chain.ChainContext.TxFactory().WithGas(gasExpected)
result, err := client.BroadcastTx(ctx, clientCtx, txf, bankSend1, bankSend2)
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/modules/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func TestWASMPinningAndUnpinningSmartContractUsingGovernance(t *testing.T) {
assertT.Greater(gasUsedAfterUnpinning, gasUsedAfterPinning)
}

// TestWASMContractUpgrade deploys simple state smart contract do its upgrade.
// TestWASMContractUpgrade deploys simple state smart contract do its upgrade and upgrades/migrates it.
func TestWASMContractUpgrade(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -496,7 +496,7 @@ func TestWASMContractUpgrade(t *testing.T) {
Count: 999,
})
requireT.NoError(err)
// try to migrate from none admin.
// try to migrate from non-admin.
err = chain.Wasm.MigrateWASMContract(ctx, txf, noneAdmin, contractAddr, newCodeID, migrationPayload)
requireT.Error(err)
requireT.Contains(err.Error(), "unauthorized")
Expand Down Expand Up @@ -778,7 +778,7 @@ func TestWASMFungibleTokenInContract(t *testing.T) {
},
BurnRate: burnRate,
SendCommissionRate: sendCommissionRate,
Version: tokenRes.Token.Version, // test should work with any token version
Version: assetfttypes.CurrentTokenVersion, // test should work with any token version
}
requireT.Equal(
expectedToken, tokenRes.Token,
Expand Down Expand Up @@ -1379,6 +1379,7 @@ func TestWASMNonFungibleTokenInContract(t *testing.T) {
requireT.NoError(json.Unmarshal(queryOut, &classQueryRes))
requireT.Equal(
moduleswasm.AssetnftClass{
// TODO Artem: compare it with Class[0].
ID: expectedClass.Id,
Issuer: expectedClass.Issuer,
Name: expectedClass.Name,
Expand Down
Loading

0 comments on commit 7eee4ac

Please sign in to comment.