Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
async
Browse files Browse the repository at this point in the history
aljo242 committed Jun 11, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 741f2fc commit 0a00233
Showing 1 changed file with 48 additions and 17 deletions.
65 changes: 48 additions & 17 deletions tests/e2e/suite.go
Original file line number Diff line number Diff line change
@@ -370,9 +370,30 @@ func (s *TestSuite) TestSendTxDecrease() {

s.Run("expect fee market state to decrease", func() {
s.T().Log("performing sends...")
for {
// send with the exact expected defaultGasPrice
sig := make(chan struct{})
quit := make(chan struct{})
defer close(quit)

checkPrice := func(c, quit chan struct{}) {
select {
case <-time.After(500 * time.Millisecond):
gasPrice := s.QueryDefaultGasPrice()
s.T().Log("gas price", gasPrice.String())

if gasPrice.Amount.Equal(params.MinBaseGasPrice) {
c <- struct{}{}
}
case <-quit:
return
}
}
go checkPrice(sig, quit)

select {
case <-sig:
break

case <-time.After(100 * time.Millisecond):
wg := sync.WaitGroup{}
wg.Add(3)

@@ -425,12 +446,6 @@ func (s *TestSuite) TestSendTxDecrease() {
}()

wg.Wait()
gasPrice := s.QueryDefaultGasPrice()
s.T().Log("base defaultGasPrice", gasPrice.String())

if gasPrice.Amount.Equal(params.MinBaseGasPrice) {
break
}
}

// wait for 5 blocks
@@ -456,17 +471,39 @@ func (s *TestSuite) TestSendTxIncrease() {
nodes := s.chain.Nodes()
s.Require().True(len(nodes) > 0)

baseGasPrice := s.QueryDefaultGasPrice()
params := s.QueryParams()

gas := int64(params.MaxBlockUtilization)
sendAmt := int64(100)

s.Run("expect fee market gas price to increase", func() {
s.T().Log("performing sends...")
for {
sig := make(chan struct{})
quit := make(chan struct{})
defer close(quit)

checkPrice := func(c, quit chan struct{}) {
select {
case <-time.After(500 * time.Millisecond):
gasPrice := s.QueryDefaultGasPrice()
s.T().Log("gas price", gasPrice.String())

if gasPrice.Amount.GT(s.txConfig.TargetIncreaseGasPrice) {
c <- struct{}{}
}
case <-quit:
return
}
}
go checkPrice(sig, quit)

select {
case <-sig:
break

case <-time.After(100 * time.Millisecond):
// send with the exact expected baseGasPrice
baseGasPrice = s.QueryDefaultGasPrice()
baseGasPrice := s.QueryDefaultGasPrice()
minBaseFee := sdk.NewDecCoinFromDec(baseGasPrice.Denom, baseGasPrice.Amount.Mul(math.LegacyNewDec(gas)))
// add headroom
minBaseFeeCoins := sdk.NewCoins(sdk.NewCoin(minBaseFee.Denom, minBaseFee.Amount.Add(math.LegacyNewDec(10)).TruncateInt()))
@@ -523,12 +560,6 @@ func (s *TestSuite) TestSendTxIncrease() {
}()

wg.Wait()
baseGasPrice = s.QueryDefaultGasPrice()
s.T().Log("gas price", baseGasPrice.String())

if baseGasPrice.Amount.GT(s.txConfig.TargetIncreaseGasPrice) {
break
}
}

// wait for 5 blocks

0 comments on commit 0a00233

Please sign in to comment.