Skip to content

Commit

Permalink
fix the calculation on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gsk967 committed Oct 17, 2023
1 parent 50c1627 commit e297422
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions tests/e2e/e2e_ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ func (s *E2ETest) TestIBCTokenTransfer() {
sdk.NewDecFromInt(tokenQuota).Quo(atomPrice).Mul(powerReduction).RoundInt(),
)

//<<<< INFLOW : gaia -> umee >>
// send $500 ATOM from gaia to umee. (ibc_quota will not check token limit)
atomFromGaia := mulCoin(atomQuota, "5.0")
atomFromGaia.Denom = "uatom"
s.SendIBC(setup.GaiaChainID, s.Chain.ID, "", atomFromGaia, false, "")
s.checkSupply(umeeAPIEndpoint, uatomIBCHash, atomFromGaia.Amount)

// <<< OUTLOW : umee -> gaia >>
// compute the amout of UMEE sent to gaia which would meet umee's token quota
umeePrice, err := s.QueryHistAvgPrice(umeeAPIEndpoint, umeeSymbol)
s.Require().NoError(err)
Expand All @@ -126,34 +128,39 @@ func (s *E2ETest) TestIBCTokenTransfer() {
sdk.NewDecFromInt(tokenQuota).Quo(umeePrice).Mul(powerReduction).RoundInt(),
)

// send $90 UMEE from umee to gaia (ibc_quota will check)
// Note: receiver is null so hermes will default send to key_name (from config) of target chain (gaia)
sendUmee := mulCoin(umeeQuota, "0.9")
s.SendIBC(s.Chain.ID, setup.GaiaChainID, "", sendUmee, false, fmt.Sprintf(
"sending %s (less than token quota) ", sendUmee.String()))
s.checkOutflows(umeeAPIEndpoint, appparams.BondDenom, true, sdk.NewDecFromInt(sendUmee.Amount), appparams.Name)
s.checkSupply(gaiaAPIEndpoint, umeeIBCHash, sendUmee.Amount)
// << TOKEN QUOTA EXCCEED >>
// send $110 UMEE from umee to gaia (token_quota is 100$)
exceedUmee := mulCoin(umeeQuota, "1.1")
s.SendIBC(s.Chain.ID, setup.GaiaChainID, "", exceedUmee, true, "")
// check the ibc (umee) quota after ibc txs - this one should have failed
// supply don't change
s.checkSupply(gaiaAPIEndpoint, umeeIBCHash, math.ZeroInt())

// send $110 ATOM from umee to gaia
exceedAtom := mulCoin(atomQuota, "1.1")
// supply will be not be decreased because sending amount is more than token quota so it will fail
s.SendIBC(s.Chain.ID, setup.GaiaChainID, "", exceedAtom, true, "uatom from umee to gaia")
s.checkSupply(umeeAPIEndpoint, uatomIBCHash, atomFromGaia.Amount)

// send $110 UMEE from umee to gaia (token_quota is 100$)
exceedUmee := mulCoin(umeeQuota, "1.1")
s.SendIBC(s.Chain.ID, setup.GaiaChainID, "", exceedUmee, true, "")
// check the ibc (umee) quota after ibc txs - this one should have failed
s.checkSupply(gaiaAPIEndpoint, umeeIBCHash, math.ZeroInt())
// << BELOW TOKEN QUOTA >>
// send $90 UMEE from umee to gaia (ibc_quota will check)
// Note: receiver is null so hermes will default send to key_name (from config) of target chain (gaia)
sendUmee := mulCoin(umeeQuota, "0.9")
s.SendIBC(s.Chain.ID, setup.GaiaChainID, "", sendUmee, false, fmt.Sprintf(
"sending %s (less than token quota) ", sendUmee.String()))
s.checkOutflows(umeeAPIEndpoint, appparams.BondDenom, true, sdk.NewDecFromInt(sendUmee.Amount), appparams.Name)
s.checkSupply(gaiaAPIEndpoint, umeeIBCHash, sendUmee.Amount)

// << BELOW TOKEN QUTOA 40$ but ATOM_QUOTA (40$)+ UMEE_QUOTA(90$) >= TOTAL QUOTA (120$) >>
// send $40 ATOM from umee to gaia
atom40 := mulCoin(atomQuota, "0.4")
s.SendIBC(s.Chain.ID, setup.GaiaChainID, "", atom40, true, "below token quota but not total quota")
// supply will be not be decreased because sending more than total quota from umee to gaia
s.checkSupply(umeeAPIEndpoint, uatomIBCHash, atomFromGaia.Amount)

// ✅ << BELOW TOKEN QUTOA 5$ but ATOM_QUOTA (5$)+ UMEE_QUOTA(90$) <= TOTAL QUOTA (120$) >>
// send $15 ATOM from umee to gaia
sendAtom := mulCoin(atomQuota, "0.15")
sendAtom := mulCoin(atomQuota, "0.05")
s.SendIBC(s.Chain.ID, setup.GaiaChainID, "", sendAtom, false, "below both quotas")
// remaing supply decreased uatom on umee
s.checkSupply(umeeAPIEndpoint, uatomIBCHash, atomFromGaia.Amount.Sub(sendAtom.Amount))
Expand Down

0 comments on commit e297422

Please sign in to comment.