From da335a91fe1c7f0c24a67e1d875a397b94808924 Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Wed, 19 Sep 2018 15:49:00 -0400 Subject: [PATCH] update NewCoin and crypto.Signature --- internal/x/paychan/endblocker_test.go | 8 ++++---- internal/x/paychan/keeper_test.go | 26 +++++++++++++------------- internal/x/paychan/test_common.go | 2 +- internal/x/paychan/types.go | 2 +- internal/x/paychan/types_test.go | 10 +++++----- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/internal/x/paychan/endblocker_test.go b/internal/x/paychan/endblocker_test.go index 62fd276e..ad363d05 100644 --- a/internal/x/paychan/endblocker_test.go +++ b/internal/x/paychan/endblocker_test.go @@ -1,9 +1,10 @@ package paychan import ( + "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" - "testing" ) func TestEndBlocker(t *testing.T) { @@ -14,7 +15,7 @@ func TestEndBlocker(t *testing.T) { ctx, _, channelKeeper, addrs, _, _, _ := createMockApp(accountSeeds) sender := addrs[0] receiver := addrs[1] - coins := sdk.Coins{sdk.NewCoin("KVA", 10)} + coins := sdk.Coins{sdk.NewInt64Coin("KVA", 10)} // create new channel channelID := ChannelID(0) // should be 0 as first channel @@ -26,11 +27,10 @@ func TestEndBlocker(t *testing.T) { channelKeeper.setChannel(ctx, channel) // create closing update and submittedUpdate - payout := Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}} + payout := Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}} update := Update{ ChannelID: channelID, Payout: payout, - //Sigs: [1]crypto.Signature{}, } sUpdate := SubmittedUpdate{ Update: update, diff --git a/internal/x/paychan/keeper_test.go b/internal/x/paychan/keeper_test.go index 145a4f28..48c2c4f3 100644 --- a/internal/x/paychan/keeper_test.go +++ b/internal/x/paychan/keeper_test.go @@ -30,7 +30,7 @@ func TestKeeper(t *testing.T) { "HappyPath", addrs[senderAccountIndex], addrs[receiverAccountIndex], - sdk.Coins{sdk.NewCoin("KVA", 10)}, + sdk.Coins{sdk.NewInt64Coin("KVA", 10)}, true, false, }, @@ -38,7 +38,7 @@ func TestKeeper(t *testing.T) { "NilAddress", sdk.AccAddress{}, sdk.AccAddress{}, - sdk.Coins{sdk.NewCoin("KVA", 10)}, + sdk.Coins{sdk.NewInt64Coin("KVA", 10)}, false, true, }, @@ -54,7 +54,7 @@ func TestKeeper(t *testing.T) { "NegativeCoins", addrs[senderAccountIndex], addrs[receiverAccountIndex], - sdk.Coins{sdk.NewCoin("KVA", -57)}, + sdk.Coins{sdk.NewInt64Coin("KVA", -57)}, false, true, }, @@ -126,7 +126,7 @@ func TestKeeper(t *testing.T) { ) ctx, coinKeeper, channelKeeper, addrs, pubKeys, privKeys, genAccFunding := createMockApp(accountSeeds) - coins := sdk.Coins{sdk.NewCoin("KVA", 10)} + coins := sdk.Coins{sdk.NewInt64Coin("KVA", 10)} // create new channel channelID := ChannelID(0) // should be 0 as first channel @@ -138,7 +138,7 @@ func TestKeeper(t *testing.T) { channelKeeper.setChannel(ctx, channel) // create closing update - payout := Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}} + payout := Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}} update := Update{ ChannelID: channelID, Payout: payout, @@ -200,14 +200,14 @@ func TestKeeper(t *testing.T) { { "HappyPath", true, - testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, senderAccountIndex, senderAccountIndex}, + testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, senderAccountIndex, senderAccountIndex}, "sameAsSubmited", false, }, { "NoChannel", false, - testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, senderAccountIndex, senderAccountIndex}, + testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, senderAccountIndex, senderAccountIndex}, "empty", true, }, @@ -221,35 +221,35 @@ func TestKeeper(t *testing.T) { { "NegativeCoins", true, - testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", -5)}, sdk.Coins{sdk.NewCoin("KVA", 15)}}, senderAccountIndex, senderAccountIndex}, + testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", -5)}, sdk.Coins{sdk.NewInt64Coin("KVA", 15)}}, senderAccountIndex, senderAccountIndex}, "empty", true, }, { "TooManyCoins", true, - testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 100)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, senderAccountIndex, senderAccountIndex}, + testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 100)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, senderAccountIndex, senderAccountIndex}, "empty", true, }, { "WrongSignature", true, - testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, senderAccountIndex, otherAccountIndex}, + testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, senderAccountIndex, otherAccountIndex}, "empty", true, }, { "WrongPubKey", true, - testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, otherAccountIndex, senderAccountIndex}, + testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, otherAccountIndex, senderAccountIndex}, "empty", true, }, { "ReceiverSigned", true, - testUpdate{chanID, Payout{sdk.Coins{sdk.NewCoin("KVA", 3)}, sdk.Coins{sdk.NewCoin("KVA", 7)}}, receiverAccountIndex, receiverAccountIndex}, + testUpdate{chanID, Payout{sdk.Coins{sdk.NewInt64Coin("KVA", 3)}, sdk.Coins{sdk.NewInt64Coin("KVA", 7)}}, receiverAccountIndex, receiverAccountIndex}, "empty", true, }, @@ -266,7 +266,7 @@ func TestKeeper(t *testing.T) { channel := Channel{ ID: chanID, // should be 0 as first channel Participants: [2]sdk.AccAddress{addrs[senderAccountIndex], addrs[receiverAccountIndex]}, - Coins: sdk.Coins{sdk.NewCoin("KVA", 10)}, + Coins: sdk.Coins{sdk.NewInt64Coin("KVA", 10)}, } channelKeeper.setChannel(ctx, channel) } diff --git a/internal/x/paychan/test_common.go b/internal/x/paychan/test_common.go index d102b27f..98e6a0df 100644 --- a/internal/x/paychan/test_common.go +++ b/internal/x/paychan/test_common.go @@ -27,7 +27,7 @@ func createMockApp(accountSeeds []string) (sdk.Context, bank.Keeper, Keeper, []s mApp.CompleteSetup([]*sdk.KVStoreKey{keyChannel}) // create some accounts - genAccFunding := sdk.Coins{sdk.NewCoin("KVA", 1000)} + genAccFunding := sdk.Coins{sdk.NewInt64Coin("KVA", 1000)} genAccs, addrs, pubKeys, privKeys := createTestGenAccounts(accountSeeds, genAccFunding) // initialize the app with these accounts diff --git a/internal/x/paychan/types.go b/internal/x/paychan/types.go index 57d44b52..3d6a8e69 100644 --- a/internal/x/paychan/types.go +++ b/internal/x/paychan/types.go @@ -61,7 +61,7 @@ func (p Payout) Sum() sdk.Coins { type UpdateSignature struct { PubKey crypto.PubKey - CryptoSignature crypto.Signature + CryptoSignature []byte } // An update that has been submitted to the blockchain, but not yet acted on. diff --git a/internal/x/paychan/types_test.go b/internal/x/paychan/types_test.go index e4004317..83c97ff6 100644 --- a/internal/x/paychan/types_test.go +++ b/internal/x/paychan/types_test.go @@ -28,18 +28,18 @@ func TestSubmittedUpdatesQueue(t *testing.T) { func TestPayout(t *testing.T) { t.Run("IsNotNegative", func(t *testing.T) { - p := Payout{sdk.Coins{sdk.NewCoin("USD", 4), sdk.NewCoin("GBP", 0)}, sdk.Coins{sdk.NewCoin("USD", 129879234), sdk.NewCoin("GBP", 1)}} + p := Payout{sdk.Coins{sdk.NewInt64Coin("USD", 4), sdk.NewInt64Coin("GBP", 0)}, sdk.Coins{sdk.NewInt64Coin("USD", 129879234), sdk.NewInt64Coin("GBP", 1)}} assert.True(t, p.IsNotNegative()) - p = Payout{sdk.Coins{sdk.NewCoin("USD", -4), sdk.NewCoin("GBP", 0)}, sdk.Coins{sdk.NewCoin("USD", 129879234), sdk.NewCoin("GBP", 1)}} + p = Payout{sdk.Coins{sdk.NewInt64Coin("USD", -4), sdk.NewInt64Coin("GBP", 0)}, sdk.Coins{sdk.NewInt64Coin("USD", 129879234), sdk.NewInt64Coin("GBP", 1)}} assert.False(t, p.IsNotNegative()) }) t.Run("Sum", func(t *testing.T) { p := Payout{ - sdk.Coins{sdk.NewCoin("EUR", 1), sdk.NewCoin("USD", -5)}, - sdk.Coins{sdk.NewCoin("EUR", 1), sdk.NewCoin("USD", 100), sdk.NewCoin("GBP", 1)}, + sdk.Coins{sdk.NewInt64Coin("EUR", 1), sdk.NewInt64Coin("USD", -5)}, + sdk.Coins{sdk.NewInt64Coin("EUR", 1), sdk.NewInt64Coin("USD", 100), sdk.NewInt64Coin("GBP", 1)}, } - expected := sdk.Coins{sdk.NewCoin("EUR", 2), sdk.NewCoin("GBP", 1), sdk.NewCoin("USD", 95)} + expected := sdk.Coins{sdk.NewInt64Coin("EUR", 2), sdk.NewInt64Coin("GBP", 1), sdk.NewInt64Coin("USD", 95)} assert.Equal(t, expected, p.Sum()) }) }