Skip to content

Commit

Permalink
Merge pull request #7 from noble-assets/spoorthi/fix-make-build-2
Browse files Browse the repository at this point in the history
chore: get build to work
spoo-bar authored Aug 23, 2024
2 parents 8162668 + b46e4d9 commit d8bceb5
Showing 21 changed files with 619 additions and 346 deletions.
38 changes: 19 additions & 19 deletions e2e/main_test.go
Original file line number Diff line number Diff line change
@@ -3,14 +3,14 @@ package e2e
import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"cosmossdk.io/math"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
"github.com/stretchr/testify/require"
)

var ONE = sdk.NewInt(1_000_000_000_000_000_000)
var ONE = math.NewInt(1_000_000_000_000_000_000)

func TestMintBurn(t *testing.T) {
t.Parallel()
@@ -34,7 +34,7 @@ func TestMintBurn(t *testing.T) {
require.NoError(t, err)
require.Equal(t, ONE.Int64(), balance)
// ASSERT: Minter has no allowance.
EnsureMinter(t, wrapper, ctx, wrapper.minter.FormattedAddress(), sdk.ZeroInt())
EnsureMinter(t, wrapper, ctx, wrapper.minter.FormattedAddress(), math.ZeroInt())

// ASSERT: Burner has an allowance of 1 $USDY.
EnsureBurner(t, wrapper, ctx, wrapper.burner.FormattedAddress(), ONE)
@@ -51,7 +51,7 @@ func TestMintBurn(t *testing.T) {
require.NoError(t, err)
require.Zero(t, balance)
// ASSERT: Burner has no allowance.
EnsureBurner(t, wrapper, ctx, wrapper.burner.FormattedAddress(), sdk.ZeroInt())
EnsureBurner(t, wrapper, ctx, wrapper.burner.FormattedAddress(), math.ZeroInt())
}

func TestMintTransferBurn(t *testing.T) {
@@ -76,13 +76,13 @@ func TestMintTransferBurn(t *testing.T) {
require.NoError(t, err)
require.Equal(t, ONE.Int64(), balance)
// ASSERT: Minter has no allowance.
EnsureMinter(t, wrapper, ctx, wrapper.minter.FormattedAddress(), sdk.ZeroInt())
EnsureMinter(t, wrapper, ctx, wrapper.minter.FormattedAddress(), math.ZeroInt())

// ACT: Transfer 1 $USDY from Alice to Bob.
err = validator.SendFunds(ctx, wrapper.alice.KeyName(), ibc.WalletAmount{
Address: wrapper.bob.FormattedAddress(),
Denom: "ausdy",
Amount: ONE.Int64(),
Amount: ONE,
})
require.NoError(t, err)

@@ -110,7 +110,7 @@ func TestMintTransferBurn(t *testing.T) {
require.NoError(t, err)
require.Zero(t, balance)
// ASSERT: Burner has no allowance.
EnsureBurner(t, wrapper, ctx, wrapper.burner.FormattedAddress(), sdk.ZeroInt())
EnsureBurner(t, wrapper, ctx, wrapper.burner.FormattedAddress(), math.ZeroInt())
}

func TestMintTransferBlockBurn(t *testing.T) {
@@ -135,13 +135,13 @@ func TestMintTransferBlockBurn(t *testing.T) {
require.NoError(t, err)
require.Equal(t, ONE.Int64(), balance)
// ASSERT: Minter has no allowance.
EnsureMinter(t, wrapper, ctx, wrapper.minter.FormattedAddress(), sdk.ZeroInt())
EnsureMinter(t, wrapper, ctx, wrapper.minter.FormattedAddress(), math.ZeroInt())

// ACT: Transfer 1 $USDY from Alice to Bob.
err = validator.SendFunds(ctx, wrapper.alice.KeyName(), ibc.WalletAmount{
Address: wrapper.bob.FormattedAddress(),
Denom: "ausdy",
Amount: ONE.Int64(),
Amount: ONE,
})
require.NoError(t, err)

@@ -168,14 +168,14 @@ func TestMintTransferBlockBurn(t *testing.T) {
err = validator.SendFunds(ctx, wrapper.bob.KeyName(), ibc.WalletAmount{
Address: wrapper.alice.FormattedAddress(),
Denom: "ausdy",
Amount: ONE.Int64(),
Amount: ONE,
})
require.ErrorContains(t, err, "blocked from sending")

// ASSERT: Bob has 1 $USDY.
balance, err = wrapper.chain.GetBalance(ctx, wrapper.bob.FormattedAddress(), "ausdy")
require.NoError(t, err)
require.Equal(t, ONE.Int64(), balance)
require.Equal(t, ONE, balance)
// ASSERT: Burner has an allowance of 1 $USDY.
EnsureBurner(t, wrapper, ctx, wrapper.burner.FormattedAddress(), ONE)

@@ -191,7 +191,7 @@ func TestMintTransferBlockBurn(t *testing.T) {
require.NoError(t, err)
require.Zero(t, balance)
// ASSERT: Burner has no allowance.
EnsureBurner(t, wrapper, ctx, wrapper.burner.FormattedAddress(), sdk.ZeroInt())
EnsureBurner(t, wrapper, ctx, wrapper.burner.FormattedAddress(), math.ZeroInt())
}

func TestIBCTransfer(t *testing.T) {
@@ -221,7 +221,7 @@ func TestIBCTransfer(t *testing.T) {
_, err = wrapper.chain.SendIBCTransfer(ctx, "channel-0", wrapper.alice.KeyName(), ibc.WalletAmount{
Address: wrapper.charlie.FormattedAddress(),
Denom: "ausdy",
Amount: ONE.MulRaw(2).Int64(),
Amount: ONE.MulRaw(2),
}, ibc.TransferOptions{})
// ASSERT: The action should've succeeded.
require.NoError(t, err)
@@ -231,23 +231,23 @@ func TestIBCTransfer(t *testing.T) {
require.Zero(t, balance)
balance, err = wrapper.gaia.GetBalance(ctx, wrapper.charlie.FormattedAddress(), denom)
require.NoError(t, err)
require.Equal(t, ONE.MulRaw(2).Int64(), balance)
require.Equal(t, ONE.MulRaw(2), balance)

// ACT: Attempt to transfer back to Noble, channel is allowed.
_, err = wrapper.gaia.SendIBCTransfer(ctx, "channel-0", wrapper.charlie.KeyName(), ibc.WalletAmount{
Address: wrapper.alice.FormattedAddress(),
Denom: denom,
Amount: ONE.Int64(),
Amount: ONE,
}, ibc.TransferOptions{})
// ASSERT: The action should've succeeded.
require.NoError(t, err)
require.NoError(t, testutil.WaitForBlocks(ctx, 5, wrapper.chain, wrapper.gaia))
balance, err = wrapper.chain.GetBalance(ctx, wrapper.alice.FormattedAddress(), "ausdy")
require.NoError(t, err)
require.Equal(t, ONE.Int64(), balance)
require.Equal(t, ONE, balance)
balance, err = wrapper.gaia.GetBalance(ctx, wrapper.charlie.FormattedAddress(), denom)
require.NoError(t, err)
require.Equal(t, ONE.Int64(), balance)
require.Equal(t, ONE, balance)

// ACT: Block transfers over channel-0.
_, err = validator.ExecTx(
@@ -262,7 +262,7 @@ func TestIBCTransfer(t *testing.T) {
_, err = wrapper.chain.SendIBCTransfer(ctx, "channel-0", wrapper.alice.KeyName(), ibc.WalletAmount{
Address: wrapper.charlie.FormattedAddress(),
Denom: "ausdy",
Amount: ONE.Int64(),
Amount: ONE,
}, ibc.TransferOptions{})
// ASSERT: The action should've failed.
require.ErrorContains(t, err, "ausdy transfers are blocked on channel-0")
@@ -271,7 +271,7 @@ func TestIBCTransfer(t *testing.T) {
_, err = wrapper.gaia.SendIBCTransfer(ctx, "channel-0", wrapper.charlie.KeyName(), ibc.WalletAmount{
Address: wrapper.alice.FormattedAddress(),
Denom: denom,
Amount: ONE.Int64(),
Amount: ONE,
}, ibc.TransferOptions{})
// ASSERT: The action should've succeeded.
require.NoError(t, err)
15 changes: 8 additions & 7 deletions e2e/utils.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
"encoding/json"
"testing"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/gogo/protobuf/jsonpb"
_ "github.com/ondoprotocol/usdy-noble/x/aura"
@@ -64,7 +65,7 @@ func Suite(t *testing.T, wrapper *Wrapper, ibcEnabled bool) (ctx context.Context
GasAdjustment: 5,
TrustingPeriod: "504h",
NoHostMount: false,
PreGenesis: func(cfg ibc.ChainConfig) (err error) {
PreGenesis: func(cfg ibc.Chain) (err error) {
validator := wrapper.chain.Validators[0]
ONE := sdk.NewCoins(sdk.NewInt64Coin("ustake", 1_000_000))

@@ -116,7 +117,7 @@ func Suite(t *testing.T, wrapper *Wrapper, ibcEnabled bool) (ctx context.Context
return nil
},
ModifyGenesis: func(cfg ibc.ChainConfig, bz []byte) ([]byte, error) {
ONE := sdk.NewInt(1_000_000_000_000_000_000)
ONE := math.NewInt(1_000_000_000_000_000_000)

changes := []cosmos.GenesisKV{
{Key: "app_state.aura.blocklist_state.owner", Value: wrapper.owner.FormattedAddress()},
@@ -131,7 +132,7 @@ func Suite(t *testing.T, wrapper *Wrapper, ibcEnabled bool) (ctx context.Context

return cosmos.ModifyGenesis(changes)(cfg, bz)
},
ModifyGenesisAmounts: func() (sdk.Coin, sdk.Coin) {
ModifyGenesisAmounts: func(int) (sdk.Coin, sdk.Coin) {
ONE := sdk.NewInt64Coin("ustake", 1_000_000)
return ONE, ONE
},
@@ -145,9 +146,9 @@ func Suite(t *testing.T, wrapper *Wrapper, ibcEnabled bool) (ctx context.Context
NumValidators: &numValidators,
NumFullNodes: &numFullNodes,
ChainConfig: ibc.ChainConfig{
PreGenesis: func(cfg ibc.ChainConfig) (err error) {
PreGenesis: func(cfg ibc.Chain) (err error) {
validator := wrapper.gaia.Validators[0]
ONE := sdk.NewCoins(sdk.NewInt64Coin(cfg.Denom, 1_000_000))
ONE := sdk.NewCoins(sdk.NewInt64Coin(cfg.Config().Denom, 1_000_000))

wrapper.charlie, err = wrapper.gaia.BuildWallet(ctx, "owner", "")
if err != nil {
@@ -223,7 +224,7 @@ func EnsureBlocked(t *testing.T, wrapper Wrapper, ctx context.Context, address s
require.True(t, res.Blocked)
}

func EnsureBurner(t *testing.T, wrapper Wrapper, ctx context.Context, address string, allowance sdk.Int) {
func EnsureBurner(t *testing.T, wrapper Wrapper, ctx context.Context, address string, allowance math.Int) {
validator := wrapper.chain.Validators[0]

raw, _, err := validator.ExecQuery(ctx, "aura", "burners")
@@ -235,7 +236,7 @@ func EnsureBurner(t *testing.T, wrapper Wrapper, ctx context.Context, address st
require.Contains(t, res.Burners, types.Burner{Address: address, Allowance: allowance})
}

func EnsureMinter(t *testing.T, wrapper Wrapper, ctx context.Context, address string, allowance sdk.Int) {
func EnsureMinter(t *testing.T, wrapper Wrapper, ctx context.Context, address string, allowance math.Int) {
validator := wrapper.chain.Validators[0]

raw, _, err := validator.ExecQuery(ctx, "aura", "minters")
Loading

0 comments on commit d8bceb5

Please sign in to comment.