From 14f69bab506a9039da0d547ff4aeeb5df318ec9f Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Mon, 8 Jan 2024 12:35:16 +0200 Subject: [PATCH] Enable storage limit for emulator backend This will make the testing environment behave more similar to a development/testnet environment. --- test/emulator_backend.go | 2 +- test/test_framework_test.go | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/emulator_backend.go b/test/emulator_backend.go index 5609e159..49dabd44 100644 --- a/test/emulator_backend.go +++ b/test/emulator_backend.go @@ -739,7 +739,7 @@ func newBlockchain( b, err := emulator.New( append( []emulator.Option{ - emulator.WithStorageLimitEnabled(false), + emulator.WithStorageLimitEnabled(true), emulator.WithServerLogger(logger), emulator.Contracts(commonContracts), emulator.WithChainID(chain.ChainID()), diff --git a/test/test_framework_test.go b/test/test_framework_test.go index 2e0dd9b4..ba9a4776 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -733,7 +733,7 @@ func TestImportContract(t *testing.T) { Test.assert(blockHeight > 1) mintFlow(to: admin, amount: 500.0) - Test.assertEqual(500.0, getFlowBalance(account: admin)) + Test.assertEqual(500.001, getFlowBalance(account: admin)) let lowestHeight = RandomBeaconHistory.getLowestHeight() Test.assertEqual(UInt64(1), lowestHeight) @@ -1155,7 +1155,7 @@ func TestUsingEnv(t *testing.T) { access(all) fun test() { let acc = getAccount(0x10) - Test.assertEqual(0.0, acc.balance) + Test.assertEqual(0.001, acc.balance) } ` @@ -1186,7 +1186,7 @@ func TestUsingEnv(t *testing.T) { access(all) fun test() { - Test.assertEqual(0.0, FooContract.getBalance()) + Test.assertEqual(0.001, FooContract.getBalance()) } ` @@ -3602,7 +3602,7 @@ func TestGetAccountFlowBalance(t *testing.T) { let balance = getFlowBalance(account: account) // Assert - Test.assertEqual(1000000000.0, balance) + Test.assertEqual(999999999.977, balance) } ` @@ -3661,7 +3661,7 @@ func TestMintFlow(t *testing.T) { // Assert let balance = getFlowBalance(account: account) - Test.assertEqual(1500.0, balance) + Test.assertEqual(1500.001, balance) } ` @@ -3689,14 +3689,14 @@ func TestBurnFlow(t *testing.T) { // Assert var balance = getFlowBalance(account: account) - Test.assertEqual(1500.0, balance) + Test.assertEqual(1500.001, balance) // Act burnFlow(from: account, amount: 500.0) // Assert balance = getFlowBalance(account: account) - Test.assertEqual(1000.0, balance) + Test.assertEqual(1000.001, balance) } ` @@ -3852,7 +3852,7 @@ func TestServiceAccount(t *testing.T) { let balance = getFlowBalance(account: account) // Assert - Test.assertEqual(1000000000.0, balance) + Test.assertEqual(999999999.977, balance) } access(all) @@ -3875,7 +3875,7 @@ func TestServiceAccount(t *testing.T) { // Assert let balance = getFlowBalance(account: receiver) - Test.assertEqual(1500.0, balance) + Test.assertEqual(1500.001, balance) } ` @@ -5077,14 +5077,14 @@ func TestBlockchainReset(t *testing.T) { // Arrange let account = Test.createAccount() var balance = getFlowBalance(account: account) - Test.assertEqual(0.0, balance) + Test.assertEqual(0.001, balance) let height = getCurrentBlockHeight() mintFlow(to: account, amount: 1500.0) balance = getFlowBalance(account: account) - Test.assertEqual(1500.0, balance) + Test.assertEqual(1500.001, balance) Test.assertEqual(getCurrentBlockHeight(), height + 1) // Act @@ -5092,7 +5092,7 @@ func TestBlockchainReset(t *testing.T) { // Assert balance = getFlowBalance(account: account) - Test.assertEqual(0.0, balance) + Test.assertEqual(0.001, balance) Test.assertEqual(getCurrentBlockHeight(), height) } ` @@ -5597,17 +5597,17 @@ func TestEmulatorBlockchainSnapshotting(t *testing.T) { Test.createSnapshot(name: "adminFunded") var balance = getFlowBalance(account: admin) - Test.assertEqual(1000.0, balance) + Test.assertEqual(1000.001, balance) Test.loadSnapshot(name: "adminCreated") balance = getFlowBalance(account: admin) - Test.assertEqual(0.0, balance) + Test.assertEqual(0.001, balance) Test.loadSnapshot(name: "adminFunded") balance = getFlowBalance(account: admin) - Test.assertEqual(1000.0, balance) + Test.assertEqual(1000.001, balance) } `