From 1c6bc1928e9473547d5d89a9937caba769da92b3 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/mainnet 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 0374806f..da665a92 100644 --- a/test/emulator_backend.go +++ b/test/emulator_backend.go @@ -741,7 +741,7 @@ func newBlockchain( b, err := emulator.New( append( []emulator.Option{ - emulator.WithStorageLimitEnabled(false), + emulator.WithStorageLimitEnabled(true), emulator.WithServerLogger(testLogger), emulator.Contracts(commonContracts), emulator.WithChainID(chain.ChainID()), diff --git a/test/test_framework_test.go b/test/test_framework_test.go index d02ad7d2..ce133539 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -735,7 +735,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) @@ -1157,7 +1157,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) } ` @@ -1188,7 +1188,7 @@ func TestUsingEnv(t *testing.T) { access(all) fun test() { - Test.assertEqual(0.0, FooContract.getBalance()) + Test.assertEqual(0.001, FooContract.getBalance()) } ` @@ -3604,7 +3604,7 @@ func TestGetAccountFlowBalance(t *testing.T) { let balance = getFlowBalance(account: account) // Assert - Test.assertEqual(1000000000.0, balance) + Test.assertEqual(999999999.977, balance) } ` @@ -3663,7 +3663,7 @@ func TestMintFlow(t *testing.T) { // Assert let balance = getFlowBalance(account: account) - Test.assertEqual(1500.0, balance) + Test.assertEqual(1500.001, balance) } ` @@ -3691,14 +3691,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) } ` @@ -3854,7 +3854,7 @@ func TestServiceAccount(t *testing.T) { let balance = getFlowBalance(account: account) // Assert - Test.assertEqual(1000000000.0, balance) + Test.assertEqual(999999999.977, balance) } access(all) @@ -3877,7 +3877,7 @@ func TestServiceAccount(t *testing.T) { // Assert let balance = getFlowBalance(account: receiver) - Test.assertEqual(1500.0, balance) + Test.assertEqual(1500.001, balance) } ` @@ -5101,14 +5101,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 @@ -5116,7 +5116,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) } ` @@ -5621,17 +5621,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) } `