Skip to content

Commit

Permalink
build tx signatures as many as necessary for the msgs (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
yys authored and dokwon committed Dec 10, 2019
1 parent 1eb8b99 commit 2e2ef16
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 12 additions & 1 deletion x/auth/client/utils/feeutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ func ComputeFeesWithStdTx(
sim := (gas == 0)

if sim {
tx.Signatures = []auth.StdSignature{{}}
tx.Signatures = []auth.StdSignature{}

signers := make(map[string]bool)
for _, msg := range tx.Msgs {
for _, signer := range msg.GetSigners() {
if _, ok := signers[signer.String()]; !ok {
signers[signer.String()] = true
tx.Signatures = append(tx.Signatures, auth.StdSignature{})
}
}
}

txBytes, err := utils.GetTxEncoder(cliCtx.Codec)(tx)
if err != nil {
return nil, 0, err
Expand Down
14 changes: 9 additions & 5 deletions x/market/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ import (
func TestReplenishPools(t *testing.T) {
input := keeper.CreateTestInput(t)

delta := sdk.NewDec(1000000)
regressionAmt := delta.QuoInt64(input.MarketKeeper.PoolRecoveryPeriod(input.Ctx))
delta := sdk.NewDecWithPrec(17987573223725367, 3)
input.MarketKeeper.SetTerraPoolDelta(input.Ctx, delta)

EndBlocker(input.Ctx, input.MarketKeeper)
for i := 0; i < 100; i++ {
delta = input.MarketKeeper.GetTerraPoolDelta(input.Ctx)
regressionAmt := delta.QuoInt64(input.MarketKeeper.PoolRecoveryPeriod(input.Ctx))

terraPoolDelta := input.MarketKeeper.GetTerraPoolDelta(input.Ctx)
require.Equal(t, delta.Sub(regressionAmt), terraPoolDelta)
EndBlocker(input.Ctx, input.MarketKeeper)

terraPoolDelta := input.MarketKeeper.GetTerraPoolDelta(input.Ctx)
require.Equal(t, delta.Sub(regressionAmt), terraPoolDelta)
}
}

0 comments on commit 2e2ef16

Please sign in to comment.