Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: power reduction for Tendermint #3400

Merged
merged 38 commits into from
Feb 6, 2019
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4ea3477
add uncompiled power functionality
rigelrozanski Jan 25, 2019
3b0f7c6
fix some compile errors
rigelrozanski Jan 25, 2019
1bd2fbf
Merge remote-tracking branch 'origin/develop' into rigel/tmint-power-…
rigelrozanski Jan 29, 2019
874f065
Power -> TendermintPower
rigelrozanski Jan 29, 2019
af5a1e3
tests rename GetTendermintPower
rigelrozanski Jan 29, 2019
5ec0826
test fix
rigelrozanski Jan 30, 2019
b792be6
working
rigelrozanski Jan 30, 2019
bce1ff0
fix delegation tests
rigelrozanski Jan 30, 2019
5fb7d78
fix slash tests
rigelrozanski Jan 30, 2019
31c2b8e
staking/keeper tests passing
rigelrozanski Jan 30, 2019
753e71b
docs reversion
rigelrozanski Jan 30, 2019
0a71ae3
debuggin workin
rigelrozanski Jan 30, 2019
500ae2d
x/staking test pass
rigelrozanski Jan 31, 2019
93a9d66
fix gov tests
rigelrozanski Jan 31, 2019
2f5ae44
fix x/slashing tests
rigelrozanski Jan 31, 2019
328b7bf
working distribution test fixes
rigelrozanski Jan 31, 2019
7958a14
fix distribution tests
rigelrozanski Jan 31, 2019
f7c7a1d
lint
rigelrozanski Jan 31, 2019
836e963
fix lcd tests
rigelrozanski Feb 1, 2019
bba4591
fix gov test
rigelrozanski Feb 1, 2019
079b4ad
lint
rigelrozanski Feb 1, 2019
ffff826
CLI fixes, rm stakingTypes
rigelrozanski Feb 1, 2019
1ab4597
typos
rigelrozanski Feb 1, 2019
6ac2afd
working cli fixes
rigelrozanski Feb 1, 2019
9f42196
Merge remote-tracking branch 'origin/develop' into rigel/tmint-power-…
rigelrozanski Feb 1, 2019
239f145
cli test fix
rigelrozanski Feb 1, 2019
8dcf0d7
cli tests fixed
rigelrozanski Feb 1, 2019
49c1a3c
testnet creation modification
rigelrozanski Feb 1, 2019
b1db0f4
typo
rigelrozanski Feb 1, 2019
d2cc658
pending
rigelrozanski Feb 1, 2019
b2241ef
Sanitize Dec.Roundint64 (#3475)
rigelrozanski Feb 2, 2019
7df1018
Merge remote-tracking branch 'origin/develop' into rigel/tmint-power-…
rigelrozanski Feb 6, 2019
cefba46
merge fixes
rigelrozanski Feb 6, 2019
5e95340
@cwgoes comments
rigelrozanski Feb 6, 2019
a952a41
fix tests
rigelrozanski Feb 6, 2019
a984da1
change power reduction to 10^-6
rigelrozanski Feb 6, 2019
450cad0
option to turn off minting for LCD tests
rigelrozanski Feb 6, 2019
f8c1ffc
Merge branch 'develop' into rigel/tmint-power-reduce
cwgoes Feb 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cli tests fixed
  • Loading branch information
rigelrozanski committed Feb 1, 2019
commit 8dcf0d73eb3c62edefae76b95473c5d06912d237
90 changes: 50 additions & 40 deletions cmd/gaia/cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ func TestGaiaCLIFeesDeduction(t *testing.T) {
require.Equal(t, fooAmt.Int64(), fooAcc.GetCoins().AmountOf(fooDenom).Int64())

// insufficient funds (coins + fees) tx fails
largeCoins := staking.TokensFromTendermintPower(10000000)
success, _, _ = f.TxSend(
keyFoo, barAddr, sdk.NewInt64Coin(fooDenom, 10000000),
keyFoo, barAddr, sdk.NewCoin(fooDenom, largeCoins),
fmt.Sprintf("--fees=%s", sdk.NewInt64Coin(feeDenom, 2)))
require.False(t, success)

Expand Down Expand Up @@ -185,45 +186,47 @@ func TestGaiaCLISend(t *testing.T) {
barAddr := f.KeyAddress(keyBar)

fooAcc := f.QueryAccount(fooAddr)
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
startTokens := staking.TokensFromTendermintPower(50)
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))

// Send some tokens from one account to the other
f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10))
sendTokens := staking.TokensFromTendermintPower(10)
f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens))
tests.WaitForNextNBlocksTM(1, f.Port)

// Ensure account balances match expected
barAcc := f.QueryAccount(barAddr)
require.Equal(t, int64(10), barAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, sendTokens, barAcc.GetCoins().AmountOf(denom))
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom))

// Test --dry-run
success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--dry-run")
success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--dry-run")
require.True(t, success)

// Check state didn't change
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom))

// test autosequencing
f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10))
f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens))
tests.WaitForNextNBlocksTM(1, f.Port)

// Ensure account balances match expected
barAcc = f.QueryAccount(barAddr)
require.Equal(t, int64(20), barAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, sendTokens.MulRaw(2), barAcc.GetCoins().AmountOf(denom))
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(30), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens.Sub(sendTokens.MulRaw(2)), fooAcc.GetCoins().AmountOf(denom))

// test memo
f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--memo='testmemo'")
f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--memo='testmemo'")
tests.WaitForNextNBlocksTM(1, f.Port)

// Ensure account balances match expected
barAcc = f.QueryAccount(barAddr)
require.Equal(t, int64(30), barAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, sendTokens.MulRaw(3), barAcc.GetCoins().AmountOf(denom))
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(20), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens.Sub(sendTokens.MulRaw(3)), fooAcc.GetCoins().AmountOf(denom))

f.Cleanup()
}
Expand All @@ -240,34 +243,36 @@ func TestGaiaCLIGasAuto(t *testing.T) {
barAddr := f.KeyAddress(keyBar)

fooAcc := f.QueryAccount(fooAddr)
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
startTokens := staking.TokensFromTendermintPower(50)
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))

// Test failure with auto gas disabled and very little gas set by hand
success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=10")
sendTokens := staking.TokensFromTendermintPower(10)
success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=10")
require.False(t, success)

// Check state didn't change
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))

// Test failure with negative gas
success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=-100")
success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=-100")
require.False(t, success)

// Check state didn't change
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))

// Test failure with 0 gas
success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=0")
success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=0")
require.False(t, success)

// Check state didn't change
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))

// Enable auto gas
success, stdout, stderr := f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=auto")
success, stdout, stderr := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=auto")
require.NotEmpty(t, stderr)
require.True(t, success)
cdc := app.MakeCodec()
Expand All @@ -283,7 +288,7 @@ func TestGaiaCLIGasAuto(t *testing.T) {

// Check state has changed accordingly
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom))

f.Cleanup()
}
Expand Down Expand Up @@ -376,14 +381,16 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
fooAddr := f.KeyAddress(keyFoo)

fooAcc := f.QueryAccount(fooAddr)
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(staking.DefaultBondDenom).Int64())
startTokens := staking.TokensFromTendermintPower(50)
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(staking.DefaultBondDenom))

proposalsQuery := f.QueryGovProposals()
require.Empty(t, proposalsQuery)

// Test submit generate only for submit proposal
proposalTokens := staking.TokensFromTendermintPower(5)
success, stdout, stderr := f.TxGovSubmitProposal(
keyFoo, "Text", "Test", "test", sdk.NewInt64Coin(denom, 5), "--generate-only")
keyFoo, "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens), "--generate-only")
require.True(t, success)
require.Empty(t, stderr)
msg := unmarshalStdTx(t, stdout)
Expand All @@ -392,11 +399,11 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
require.Equal(t, 0, len(msg.GetSignatures()))

// Test --dry-run
success, _, _ = f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewInt64Coin(denom, 5), "--dry-run")
success, _, _ = f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens), "--dry-run")
require.True(t, success)

// Create the proposal
f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewInt64Coin(denom, 5))
f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens))
tests.WaitForNextNBlocksTM(1, f.Port)

// Ensure transaction tags can be queried
Expand All @@ -405,7 +412,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {

// Ensure deposit was deducted
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(45), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens.Sub(proposalTokens), fooAcc.GetCoins().AmountOf(denom))

// Ensure propsal is directly queryable
proposal1 := f.QueryGovProposal(1)
Expand All @@ -418,10 +425,11 @@ func TestGaiaCLISubmitProposal(t *testing.T) {

// Query the deposits on the proposal
deposit := f.QueryGovDeposit(1, fooAddr)
require.Equal(t, int64(5), deposit.Amount.AmountOf(denom).Int64())
require.Equal(t, proposalTokens, deposit.Amount.AmountOf(denom))

// Test deposit generate only
success, stdout, stderr = f.TxGovDeposit(1, keyFoo, sdk.NewInt64Coin(denom, 10), "--generate-only")
depositTokens := staking.TokensFromTendermintPower(10)
success, stdout, stderr = f.TxGovDeposit(1, keyFoo, sdk.NewCoin(denom, depositTokens), "--generate-only")
require.True(t, success)
require.Empty(t, stderr)
msg = unmarshalStdTx(t, stdout)
Expand All @@ -430,25 +438,25 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
require.Equal(t, 0, len(msg.GetSignatures()))

// Run the deposit transaction
f.TxGovDeposit(1, keyFoo, sdk.NewInt64Coin(denom, 10))
f.TxGovDeposit(1, keyFoo, sdk.NewCoin(denom, depositTokens))
tests.WaitForNextNBlocksTM(1, f.Port)

// test query deposit
deposits := f.QueryGovDeposits(1)
require.Len(t, deposits, 1)
require.Equal(t, int64(15), deposits[0].Amount.AmountOf(denom).Int64())
require.Equal(t, proposalTokens.Add(depositTokens), deposits[0].Amount.AmountOf(denom))

// Ensure querying the deposit returns the proper amount
deposit = f.QueryGovDeposit(1, fooAddr)
require.Equal(t, int64(15), deposit.Amount.AmountOf(denom).Int64())
require.Equal(t, proposalTokens.Add(depositTokens), deposit.Amount.AmountOf(denom))

// Ensure tags are set on the transaction
txs = f.QueryTxs(1, 50, "action:deposit", fmt.Sprintf("depositor:%s", fooAddr))
require.Len(t, txs, 1)

// Ensure account has expected amount of funds
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(35), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, startTokens.Sub(proposalTokens.Add(depositTokens)), fooAcc.GetCoins().AmountOf(denom))

// Fetch the proposal and ensure it is now in the voting period
proposal1 = f.QueryGovProposal(1)
Expand Down Expand Up @@ -492,7 +500,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
require.Equal(t, uint64(1), proposalsQuery[0].GetProposalID())

// submit a second test proposal
f.TxGovSubmitProposal(keyFoo, "Text", "Apples", "test", sdk.NewInt64Coin(denom, 5))
f.TxGovSubmitProposal(keyFoo, "Text", "Apples", "test", sdk.NewCoin(denom, proposalTokens))
tests.WaitForNextNBlocksTM(1, f.Port)

// Test limit on proposals query
Expand Down Expand Up @@ -612,7 +620,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
barAddr := f.KeyAddress(keyBar)

// Test generate sendTx with default gas
success, stdout, stderr := f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--generate-only")
sendTokens := staking.TokensFromTendermintPower(10)
success, stdout, stderr := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--generate-only")
require.True(t, success)
require.Empty(t, stderr)
msg := unmarshalStdTx(t, stdout)
Expand All @@ -621,7 +630,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
require.Equal(t, 0, len(msg.GetSignatures()))

// Test generate sendTx with --gas=$amount
success, stdout, stderr = f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=100", "--generate-only")
success, stdout, stderr = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=100", "--generate-only")
require.True(t, success)
require.Empty(t, stderr)
msg = unmarshalStdTx(t, stdout)
Expand All @@ -630,7 +639,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
require.Equal(t, 0, len(msg.GetSignatures()))

// Test generate sendTx, estimate gas
success, stdout, stderr = f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=auto", "--generate-only")
success, stdout, stderr = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=auto", "--generate-only")
require.True(t, success)
require.NotEmpty(t, stderr)
msg = unmarshalStdTx(t, stdout)
Expand Down Expand Up @@ -666,7 +675,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {

// Ensure foo has right amount of funds
fooAcc := f.QueryAccount(fooAddr)
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
startTokens := staking.TokensFromTendermintPower(50)
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))

// Test broadcast
success, stdout, _ = f.TxBroadcast(signedTxFile.Name())
Expand All @@ -685,8 +695,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
// Ensure account state
barAcc := f.QueryAccount(barAddr)
fooAcc = f.QueryAccount(fooAddr)
require.Equal(t, int64(10), barAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64())
require.Equal(t, sendTokens, barAcc.GetCoins().AmountOf(denom))
require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom))

f.Cleanup()
}
Expand Down