Skip to content

Commit f14fb0e

Browse files
committed
Remove line
1 parent 08148e5 commit f14fb0e

File tree

1 file changed

+18
-22
lines changed
  • docs/blockchain-development-tutorials/cadence/fork-testing

1 file changed

+18
-22
lines changed

docs/blockchain-development-tutorials/cadence/fork-testing/index.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ You'll create a complete fork testing setup that demonstrates:
5656
- Executing transactions using impersonated mainnet accounts
5757
- A reusable pattern for integration testing your Flow applications
5858

59-
**Time Commitment:** Approximately 30 minutes
60-
6159
### Reproducibility first
6260

6361
Pin a specific block height when you need reproducible results:
@@ -179,9 +177,9 @@ access(all) fun testFlowTokenSupplyIsPositive() {
179177
Test.readFile("../scripts/GetFlowTokenSupply.cdc"),
180178
[]
181179
)
182-
180+
183181
Test.expect(scriptResult, Test.beSucceeded())
184-
182+
185183
let supply = scriptResult.returnValue! as! UFix64
186184
Test.assert(supply > 0.0, message: "FlowToken supply should be positive")
187185
}
@@ -246,17 +244,17 @@ This creates `cadence/contracts/TokenChecker.cdc` and adds it to `flow.json`. No
246244
import "FlowToken"
247245
248246
access(all) contract TokenChecker {
249-
247+
250248
access(all) fun checkBalance(address: Address): UFix64 {
251249
let account = getAccount(address)
252-
250+
253251
let vaultRef = account.capabilities
254252
.borrow<&FlowToken.Vault>(/public/flowTokenBalance)
255253
?? panic("Could not borrow FlowToken Vault reference")
256-
254+
257255
return vaultRef.balance
258256
}
259-
257+
260258
access(all) fun hasMinimumBalance(address: Address, minimum: UFix64): Bool {
261259
return self.checkBalance(address: address) >= minimum
262260
}
@@ -348,9 +346,9 @@ access(all) fun testCheckBalanceOnRealAccount() {
348346
Test.readFile("../scripts/CheckBalance.cdc"),
349347
[Address(0x1654653399040a61)] // Flow service account on mainnet
350348
)
351-
349+
352350
Test.expect(scriptResult, Test.beSucceeded())
353-
351+
354352
let balance = scriptResult.returnValue! as! UFix64
355353
// The Flow service account should have a balance
356354
Test.assert(balance > 0.0, message: "Service account should have FLOW tokens")
@@ -361,9 +359,9 @@ access(all) fun testHasMinimumBalance() {
361359
Test.readFile("../scripts/HasMinimumBalance.cdc"),
362360
[Address(0x1654653399040a61), 1.0]
363361
)
364-
362+
365363
Test.expect(scriptResult, Test.beSucceeded())
366-
364+
367365
let hasMinimum = scriptResult.returnValue! as! Bool
368366
Test.assert(hasMinimum == true, message: "Service account should have at least 1 FLOW")
369367
}
@@ -444,18 +442,18 @@ access(all) fun testTransactionAsMainnetAccount() {
444442
// Impersonate the Flow service account (or any mainnet account)
445443
// No private keys needed - fork testing has built-in impersonation
446444
let serviceAccount = Test.getAccount(0x1654653399040a61)
447-
445+
448446
// Check initial balance
449447
let initialBalanceScript = Test.executeScript(
450448
Test.readFile("../scripts/CheckBalance.cdc"),
451449
[serviceAccount.address]
452450
)
453451
Test.expect(initialBalanceScript, Test.beSucceeded())
454452
let initialBalance = initialBalanceScript.returnValue! as! UFix64
455-
453+
456454
// Create a test recipient account and set up FlowToken vault
457455
let recipient = Test.createAccount()
458-
456+
459457
// Set up the recipient's FlowToken vault
460458
let setupResult = Test.executeTransaction(
461459
Test.Transaction(
@@ -466,7 +464,7 @@ access(all) fun testTransactionAsMainnetAccount() {
466464
)
467465
)
468466
Test.expect(setupResult, Test.beSucceeded())
469-
467+
470468
// Execute transaction AS the mainnet service account
471469
// This works because fork testing allows impersonating any account
472470
let txResult = Test.executeTransaction(
@@ -477,20 +475,20 @@ access(all) fun testTransactionAsMainnetAccount() {
477475
arguments: [10.0, recipient.address]
478476
)
479477
)
480-
478+
481479
Test.expect(txResult, Test.beSucceeded())
482-
480+
483481
// Verify the sender's balance decreased
484482
let newBalanceScript = Test.executeScript(
485483
Test.readFile("../scripts/CheckBalance.cdc"),
486484
[serviceAccount.address]
487485
)
488486
Test.expect(newBalanceScript, Test.beSucceeded())
489487
let newBalance = newBalanceScript.returnValue! as! UFix64
490-
488+
491489
// Balance should have decreased by exactly the transfer amount
492490
Test.assertEqual(initialBalance - 10.0, newBalance)
493-
491+
494492
// Verify the recipient received the tokens
495493
let recipientBalanceScript = Test.executeScript(
496494
Test.readFile("../scripts/CheckBalance.cdc"),
@@ -614,5 +612,3 @@ Fork testing bridges the gap between local unit tests and testnet deployments, e
614612
[Flow Networks]: ../../../protocol/flow-networks/index.md
615613
[Testing Strategy on Flow]: ../../../build/cadence/smart-contracts/testing-strategy.md
616614
[Flow Emulator]: ../../../build/tools/emulator/index.md
617-
618-

0 commit comments

Comments
 (0)