Skip to content

Commit b20eed6

Browse files
committed
fix: Increased jitter tolerance
1 parent 29189ef commit b20eed6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

tests/integration/cli_diddoc_pricing_negative_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() {
276276

277277
By("checking that the fee payer account balance has been decreased only by the actual tax")
278278
diff := balanceBefore.Amount.Sub(balanceAfter.Amount)
279-
Expect(diff).To(BeEquivalentTo(taxInCheqd.AmountOf(tax.Denom)))
279+
expected := taxInCheqd.AmountOf(tax.Denom)
280+
deviation := diff.Sub(expected).Abs()
281+
tolerance := sdkmath.NewInt(helpers.OracleJitterTolerance)
282+
Expect(
283+
deviation.LTE(tolerance),
284+
).To(BeTrue(), "fee deviation %s exceeded tolerance %d", deviation, helpers.OracleJitterTolerance)
280285
})
281286

282287
It("should charge more than tax for deactivate diddoc message - case: fee range between min and max", func() {
@@ -320,9 +325,15 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() {
320325
By("querying the fee payer account balance after the transaction")
321326
balanceAfter, err := cli.QueryBalance(testdata.BASE_ACCOUNT_5_ADDR, types.BaseMinimalDenom)
322327
Expect(err).To(BeNil())
328+
323329
By("checking that the fee payer account balance has been decreased by the tax")
324330
diff := balanceBefore.Amount.Sub(balanceAfter.Amount)
325-
Expect(diff).To(Equal(convertedFees.AmountOf(types.BaseMinimalDenom)))
331+
expected := convertedFees.AmountOf(types.BaseMinimalDenom)
332+
deviation := diff.Sub(expected).Abs()
333+
tolerance := sdkmath.NewInt(helpers.OracleJitterTolerance)
334+
Expect(
335+
deviation.LTE(tolerance),
336+
).To(BeTrue(), "fee deviation %s exceeded tolerance %d", deviation, helpers.OracleJitterTolerance)
326337
})
327338

328339
It("should not succeed in create diddoc create message - case: fixed fee, insufficient funds", func() {

tests/integration/helpers/const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ const (
44
// OracleJitterTolerance is the tolerance for oracle price fluctuations
55
OracleJitterTolerance = int64(5e8) // 500_000_000 ncheq
66
// BalanceJitterTolerance is the tolerance for account balance fluctuations; this is higher than OracleJitterTolerance to account for multiple txs or ICQ twap updates (generally higher slippage - ICQ is less predictable and takes precedence, if moving averages not yet computed)
7-
BalanceJitterTolerance = int64(4e8) // 400_000_000 ncheq
7+
BalanceJitterTolerance = int64(1e9) // 1_000_000_000 ncheq
88
)

0 commit comments

Comments
 (0)