From 62f04a96e58185147eb797c53ddf84a9e7623bfb Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Wed, 11 Oct 2023 17:55:05 -0400 Subject: [PATCH] fix: make tests use delta's --- .../internal/test/simulate_transaction_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index a2c7117d5..0dbe11b1a 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -232,9 +232,9 @@ func TestSimulateTransactionSucceeds(t *testing.T) { }, }, }, - Instructions: 6070660, + Instructions: 6062311, ReadBytes: 48, - WriteBytes: 7060, + WriteBytes: 7048, }, RefundableFee: 20056, } @@ -243,7 +243,11 @@ func TestSimulateTransactionSucceeds(t *testing.T) { var transactionData xdr.SorobanTransactionData err := xdr.SafeUnmarshalBase64(result.TransactionData, &transactionData) assert.NoError(t, err) - assert.Equal(t, expectedTransactionData, transactionData) + assert.Equal(t, expectedTransactionData.Resources.Footprint, transactionData.Resources.Footprint) + assert.InDelta(t, uint32(expectedTransactionData.Resources.Instructions), uint32(transactionData.Resources.Instructions), 100000) + assert.InDelta(t, uint32(expectedTransactionData.Resources.ReadBytes), uint32(transactionData.Resources.ReadBytes), 10) + assert.InDelta(t, uint32(expectedTransactionData.Resources.WriteBytes), uint32(transactionData.Resources.WriteBytes), 100) + assert.InDelta(t, int64(expectedTransactionData.RefundableFee), int64(transactionData.RefundableFee), 1000) // Then decode and check the result xdr, separately so we get a decent diff if it fails. assert.Len(t, result.Results, 1) @@ -1154,8 +1158,9 @@ func TestSimulateSystemEvent(t *testing.T) { err = xdr.SafeUnmarshalBase64(response.TransactionData, &transactionData) require.NoError(t, err) - assert.Equal(t, xdr.Int64(45), transactionData.RefundableFee) - assert.Equal(t, xdr.Uint32(7260), transactionData.Resources.ReadBytes) - assert.Equal(t, xdr.Uint32(104), transactionData.Resources.WriteBytes) + assert.InDelta(t, 7260, uint32(transactionData.Resources.ReadBytes), 200) + print(transactionData.RefundableFee) + assert.InDelta(t, 45, int64(transactionData.RefundableFee), 10) + assert.InDelta(t, 104, uint32(transactionData.Resources.WriteBytes), 15) require.GreaterOrEqual(t, len(response.Events), 3) }