parent
bfcb214c55
commit
b8541c8174
|
@ -62,7 +62,7 @@ func TestIncrementsMsgDelegate(t *testing.T) {
|
||||||
msgDelegate := newTestMsgDelegate(bondAmount, delegatorAddr, candidateAddr)
|
msgDelegate := newTestMsgDelegate(bondAmount, delegatorAddr, candidateAddr)
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
got := handleMsgDelegate(ctx, msgDelegate, keeper)
|
got := handleMsgDelegate(ctx, msgDelegate, keeper)
|
||||||
assert.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
require.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
||||||
|
|
||||||
//Check that the accounts and the bond account have the appropriate values
|
//Check that the accounts and the bond account have the appropriate values
|
||||||
candidates := keeper.GetCandidates(ctx, 100)
|
candidates := keeper.GetCandidates(ctx, 100)
|
||||||
|
@ -70,8 +70,8 @@ func TestIncrementsMsgDelegate(t *testing.T) {
|
||||||
expectedDelegator := initBond - expectedBond
|
expectedDelegator := initBond - expectedBond
|
||||||
gotBonded := candidates[0].Liabilities.Evaluate()
|
gotBonded := candidates[0].Liabilities.Evaluate()
|
||||||
gotDelegator := accMapper.GetAccount(ctx, delegatorAddr).GetCoins().AmountOf(params.BondDenom)
|
gotDelegator := accMapper.GetAccount(ctx, delegatorAddr).GetCoins().AmountOf(params.BondDenom)
|
||||||
assert.Equal(t, expectedBond, gotBonded, "i: %v, %v, %v", i, expectedBond, gotBonded)
|
require.Equal(t, expectedBond, gotBonded, "i: %v, %v, %v", i, expectedBond, gotBonded)
|
||||||
assert.Equal(t, expectedDelegator, gotDelegator, "i: %v, %v, %v", i, expectedDelegator, gotDelegator) // XXX fix
|
require.Equal(t, expectedDelegator, gotDelegator, "i: %v, %v, %v", i, expectedDelegator, gotDelegator) // XXX fix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ func TestIncrementsMsgUnbond(t *testing.T) {
|
||||||
numUnbonds := 5
|
numUnbonds := 5
|
||||||
for i := 0; i < numUnbonds; i++ {
|
for i := 0; i < numUnbonds; i++ {
|
||||||
got := handleMsgUnbond(ctx, msgUnbond, keeper)
|
got := handleMsgUnbond(ctx, msgUnbond, keeper)
|
||||||
assert.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
require.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
||||||
|
|
||||||
//Check that the accounts and the bond account have the appropriate values
|
//Check that the accounts and the bond account have the appropriate values
|
||||||
candidate, found := keeper.GetCandidate(ctx, candidateAddr)
|
candidate, found := keeper.GetCandidate(ctx, candidateAddr)
|
||||||
|
@ -106,8 +106,8 @@ func TestIncrementsMsgUnbond(t *testing.T) {
|
||||||
gotBonded := candidate.Liabilities.Evaluate()
|
gotBonded := candidate.Liabilities.Evaluate()
|
||||||
gotDelegator := accMapper.GetAccount(ctx, delegatorAddr).GetCoins().AmountOf(params.BondDenom)
|
gotDelegator := accMapper.GetAccount(ctx, delegatorAddr).GetCoins().AmountOf(params.BondDenom)
|
||||||
|
|
||||||
assert.Equal(t, expectedBond, gotBonded, "%v, %v", expectedBond, gotBonded)
|
require.Equal(t, expectedBond, gotBonded, "%v, %v", expectedBond, gotBonded)
|
||||||
assert.Equal(t, expectedDelegator, gotDelegator, "%v, %v", expectedDelegator, gotDelegator)
|
require.Equal(t, expectedDelegator, gotDelegator, "%v, %v", expectedDelegator, gotDelegator)
|
||||||
}
|
}
|
||||||
|
|
||||||
// these are more than we have bonded now
|
// these are more than we have bonded now
|
||||||
|
@ -122,7 +122,7 @@ func TestIncrementsMsgUnbond(t *testing.T) {
|
||||||
unbondShares := strconv.Itoa(int(c))
|
unbondShares := strconv.Itoa(int(c))
|
||||||
msgUnbond := NewMsgUnbond(delegatorAddr, candidateAddr, unbondShares)
|
msgUnbond := NewMsgUnbond(delegatorAddr, candidateAddr, unbondShares)
|
||||||
got = handleMsgUnbond(ctx, msgUnbond, keeper)
|
got = handleMsgUnbond(ctx, msgUnbond, keeper)
|
||||||
assert.False(t, got.IsOK(), "expected unbond msg to fail")
|
require.False(t, got.IsOK(), "expected unbond msg to fail")
|
||||||
}
|
}
|
||||||
|
|
||||||
leftBonded := initBond - unbondShares*int64(numUnbonds)
|
leftBonded := initBond - unbondShares*int64(numUnbonds)
|
||||||
|
@ -148,7 +148,7 @@ func TestMultipleMsgDeclareCandidacy(t *testing.T) {
|
||||||
for i, candidateAddr := range candidateAddrs {
|
for i, candidateAddr := range candidateAddrs {
|
||||||
msgDeclareCandidacy := newTestMsgDeclareCandidacy(candidateAddr, pks[i], 10)
|
msgDeclareCandidacy := newTestMsgDeclareCandidacy(candidateAddr, pks[i], 10)
|
||||||
got := handleMsgDeclareCandidacy(ctx, msgDeclareCandidacy, keeper)
|
got := handleMsgDeclareCandidacy(ctx, msgDeclareCandidacy, keeper)
|
||||||
assert.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
require.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
||||||
|
|
||||||
//Check that the account is bonded
|
//Check that the account is bonded
|
||||||
candidates := keeper.GetCandidates(ctx, 100)
|
candidates := keeper.GetCandidates(ctx, 100)
|
||||||
|
@ -156,9 +156,9 @@ func TestMultipleMsgDeclareCandidacy(t *testing.T) {
|
||||||
val := candidates[i]
|
val := candidates[i]
|
||||||
balanceExpd := initBond - 10
|
balanceExpd := initBond - 10
|
||||||
balanceGot := accMapper.GetAccount(ctx, val.Address).GetCoins().AmountOf(params.BondDenom)
|
balanceGot := accMapper.GetAccount(ctx, val.Address).GetCoins().AmountOf(params.BondDenom)
|
||||||
assert.Equal(t, i+1, len(candidates), "expected %d candidates got %d, candidates: %v", i+1, len(candidates), candidates)
|
require.Equal(t, i+1, len(candidates), "expected %d candidates got %d, candidates: %v", i+1, len(candidates), candidates)
|
||||||
assert.Equal(t, 10, int(val.Liabilities.Evaluate()), "expected %d shares, got %d", 10, val.Liabilities)
|
require.Equal(t, 10, int(val.Liabilities.Evaluate()), "expected %d shares, got %d", 10, val.Liabilities)
|
||||||
assert.Equal(t, balanceExpd, balanceGot, "expected account to have %d, got %d", balanceExpd, balanceGot)
|
require.Equal(t, balanceExpd, balanceGot, "expected account to have %d, got %d", balanceExpd, balanceGot)
|
||||||
}
|
}
|
||||||
|
|
||||||
// unbond them all
|
// unbond them all
|
||||||
|
@ -167,19 +167,19 @@ func TestMultipleMsgDeclareCandidacy(t *testing.T) {
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
msgUnbond := NewMsgUnbond(candidateAddr, candidateAddr, "10") // self-delegation
|
msgUnbond := NewMsgUnbond(candidateAddr, candidateAddr, "10") // self-delegation
|
||||||
got := handleMsgUnbond(ctx, msgUnbond, keeper)
|
got := handleMsgUnbond(ctx, msgUnbond, keeper)
|
||||||
assert.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
require.True(t, got.IsOK(), "expected msg %d to be ok, got %v", i, got)
|
||||||
|
|
||||||
//Check that the account is unbonded
|
//Check that the account is unbonded
|
||||||
candidates := keeper.GetCandidates(ctx, 100)
|
candidates := keeper.GetCandidates(ctx, 100)
|
||||||
assert.Equal(t, len(candidateAddrs)-(i+1), len(candidates),
|
require.Equal(t, len(candidateAddrs)-(i+1), len(candidates),
|
||||||
"expected %d candidates got %d", len(candidateAddrs)-(i+1), len(candidates))
|
"expected %d candidates got %d", len(candidateAddrs)-(i+1), len(candidates))
|
||||||
|
|
||||||
candidatePost, found := keeper.GetCandidate(ctx, candidateAddr)
|
candidatePost, found := keeper.GetCandidate(ctx, candidateAddr)
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
balanceExpd := initBond
|
balanceExpd := initBond
|
||||||
balanceGot := accMapper.GetAccount(ctx, candidatePre.Address).GetCoins().AmountOf(params.BondDenom)
|
balanceGot := accMapper.GetAccount(ctx, candidatePre.Address).GetCoins().AmountOf(params.BondDenom)
|
||||||
assert.Nil(t, candidatePost, "expected nil candidate retrieve, got %d", 0, candidatePost)
|
require.Nil(t, candidatePost, "expected nil candidate retrieve, got %d", 0, candidatePost)
|
||||||
assert.Equal(t, balanceExpd, balanceGot, "expected account to have %d, got %d", balanceExpd, balanceGot)
|
require.Equal(t, balanceExpd, balanceGot, "expected account to have %d, got %d", balanceExpd, balanceGot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ func TestMultipleMsgDelegate(t *testing.T) {
|
||||||
//Check that the account is bonded
|
//Check that the account is bonded
|
||||||
bond, found := keeper.getDelegatorBond(ctx, delegatorAddr, candidateAddr)
|
bond, found := keeper.getDelegatorBond(ctx, delegatorAddr, candidateAddr)
|
||||||
require.True(t, found)
|
require.True(t, found)
|
||||||
assert.NotNil(t, bond, "expected delegatee bond %d to exist", bond)
|
require.NotNil(t, bond, "expected delegatee bond %d to exist", bond)
|
||||||
}
|
}
|
||||||
|
|
||||||
// unbond them all
|
// unbond them all
|
||||||
|
|
|
@ -576,7 +576,7 @@ func TestPool(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInitGenesis(t *testing.T) {
|
func TestInitGenesis(t *testing.T) {
|
||||||
ctx, _, keeper := createTestInput(t, nil, false, 0)
|
ctx, _, keeper := createTestInput(t, false, 0)
|
||||||
jsonStr := `{
|
jsonStr := `{
|
||||||
"params": {
|
"params": {
|
||||||
"inflation_rate_change": {"num": 13, "denom": 100},
|
"inflation_rate_change": {"num": 13, "denom": 100},
|
||||||
|
|
Loading…
Reference in New Issue