diff --git a/01-wallet/test/npmton/step7.expected.txt b/01-wallet/test/npmton/step7.expected.txt index 0dbfb77..b311788 100644 --- a/01-wallet/test/npmton/step7.expected.txt +++ b/01-wallet/test/npmton/step7.expected.txt @@ -1,2 +1,2 @@ -kQCJRglfvsQzAIF0UAhkYH6zkdGPFxVNYMH1nPTN_UpDqEFK +kQCZUERmve5FUsuHkT5VYzkn-nDnp150p23hvJ1_D25Ji-p1 workchain: 0 diff --git a/01-wallet/test/npmton/step7.ts b/01-wallet/test/npmton/step7.ts index 0cd05e4..b6596ff 100644 --- a/01-wallet/test/npmton/step7.ts +++ b/01-wallet/test/npmton/step7.ts @@ -5,8 +5,8 @@ import { mnemonicToWalletKey } from "@ton/crypto"; import { WalletContractV4 } from "@ton/ton"; async function main() { - // open wallet v4 (notice the correct wallet version here) - const mnemonic = process.env.MNEMONIC;; // your 24 secret words (replace ... with the rest of the words) + // Update step7.expected.txt before running the test, since it depends on your wallet address + const mnemonic = process.env.MNEMONIC; // your 24 secret words (replace ... with the rest of the words) const key = await mnemonicToWalletKey(mnemonic!.split(" ")); const wallet = WalletContractV4.create({ publicKey: key.publicKey, workchain: 0 }); @@ -17,4 +17,4 @@ async function main() { console.log("workchain:", wallet.address.workChain); } -main(); \ No newline at end of file +main(); diff --git a/01-wallet/test/tonweb/step7.expected.txt b/01-wallet/test/tonweb/step7.expected.txt index 0dbfb77..857673d 100644 --- a/01-wallet/test/tonweb/step7.expected.txt +++ b/01-wallet/test/tonweb/step7.expected.txt @@ -1,2 +1,2 @@ -kQCJRglfvsQzAIF0UAhkYH6zkdGPFxVNYMH1nPTN_UpDqEFK +kQBqDnstKfW_YP0YN6kt3uMzSwH1FT_UM7cFyhuw6my3c3Id workchain: 0 diff --git a/01-wallet/test/tonweb/step7.ts b/01-wallet/test/tonweb/step7.ts index 497be11..4f270d8 100644 --- a/01-wallet/test/tonweb/step7.ts +++ b/01-wallet/test/tonweb/step7.ts @@ -5,6 +5,7 @@ import { mnemonicToKeyPair } from "tonweb-mnemonic"; import TonWeb from "tonweb"; async function main() { + // Update step7.expected.txt before running the test, since it depends on your wallet address const mnemonic = process.env.MNEMONIC; // your 24 secret words (replace ... with the rest of the words) const key = await mnemonicToKeyPair(mnemonic!.split(" ")); @@ -21,4 +22,4 @@ async function main() { console.log("workchain:", walletAddress.wc); } -main(); \ No newline at end of file +main(); diff --git a/02-contract/test/counter.step10.ts b/02-contract/test/counter.step10.ts index 52a9412..416b2d2 100644 --- a/02-contract/test/counter.step10.ts +++ b/02-contract/test/counter.step10.ts @@ -1,4 +1,4 @@ -import { Contract, ContractProvider, Sender, Address, Cell, contractAddress, beginCell } from "@ton/core"; +import { Contract, ContractProvider, Sender, Address, Cell, contractAddress, beginCell } from "ton-core"; export default class Counter implements Contract { @@ -10,7 +10,7 @@ export default class Counter implements Contract { const address = contractAddress(workchain, { code, data }); return new Counter(address, { code, data }); } - + constructor(readonly address: Address, readonly init?: { code: Cell, data: Cell }) {} async sendDeploy(provider: ContractProvider, via: Sender) { @@ -19,7 +19,7 @@ export default class Counter implements Contract { bounce: false }); } - + async sendIncrement(provider: ContractProvider, via: Sender) { const messageBody = beginCell() .storeUint(1, 32) // op (op #1 = increment) @@ -35,4 +35,4 @@ export default class Counter implements Contract { const { stack } = await provider.get("counter", []); return stack.readBigNumber(); } -} \ No newline at end of file +} diff --git a/02-contract/test/counter.step7.ts b/02-contract/test/counter.step7.ts index 74b795a..bf1d963 100644 --- a/02-contract/test/counter.step7.ts +++ b/02-contract/test/counter.step7.ts @@ -1,4 +1,4 @@ -import { Contract, ContractProvider, Sender, Address, Cell, contractAddress, beginCell } from "@ton/core"; +import { Contract, ContractProvider, Sender, Address, Cell, contractAddress, beginCell } from "ton-core"; export default class Counter implements Contract { @@ -10,7 +10,7 @@ export default class Counter implements Contract { const address = contractAddress(workchain, { code, data }); return new Counter(address, { code, data }); } - + constructor(readonly address: Address, readonly init?: { code: Cell, data: Cell }) {} async sendDeploy(provider: ContractProvider, via: Sender) { @@ -18,5 +18,5 @@ export default class Counter implements Contract { value: "0.01", // send 0.01 TON to contract for rent bounce: false }); - } -} \ No newline at end of file + } +} diff --git a/02-contract/test/counter.step9.ts b/02-contract/test/counter.step9.ts index 9a0ed13..5febb5d 100644 --- a/02-contract/test/counter.step9.ts +++ b/02-contract/test/counter.step9.ts @@ -1,4 +1,4 @@ -import { Contract, ContractProvider, Sender, Address, Cell, contractAddress, beginCell } from "@ton/core"; +import { Contract, ContractProvider, Sender, Address, Cell, contractAddress, beginCell } from "ton-core"; export default class Counter implements Contract { @@ -10,7 +10,7 @@ export default class Counter implements Contract { const address = contractAddress(workchain, { code, data }); return new Counter(address, { code, data }); } - + constructor(readonly address: Address, readonly init?: { code: Cell, data: Cell }) {} async sendDeploy(provider: ContractProvider, via: Sender) { @@ -19,9 +19,9 @@ export default class Counter implements Contract { bounce: false }); } - + async getCounter(provider: ContractProvider) { const { stack } = await provider.get("counter", []); return stack.readBigNumber(); } -} \ No newline at end of file +} diff --git a/02-contract/test/deploy.step8.ts b/02-contract/test/deploy.step8.ts index 360674d..16486cf 100644 --- a/02-contract/test/deploy.step8.ts +++ b/02-contract/test/deploy.step8.ts @@ -3,8 +3,8 @@ dotenv.config({ path: "../../.env" }); import * as fs from "fs"; import { getHttpEndpoint } from "@orbs-network/ton-access"; -import { mnemonicToWalletKey } from "@ton/crypto"; -import { TonClient, Cell, WalletContractV4 } from "@ton/ton"; +import { mnemonicToWalletKey } from "ton-crypto"; +import { TonClient, Cell, WalletContractV4 } from "ton"; import Counter from "./counter.step7"; // this is the interface class from step 7 export async function run() { @@ -51,6 +51,8 @@ export async function run() { console.log("deploy transaction confirmed!"); } +run(); + function sleep(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); } diff --git a/02-contract/test/step9.expected.txt b/02-contract/test/getCounter.expected.txt similarity index 100% rename from 02-contract/test/step9.expected.txt rename to 02-contract/test/getCounter.expected.txt diff --git a/02-contract/test/getCounter.ts b/02-contract/test/getCounter.ts index a403e2d..713222b 100644 --- a/02-contract/test/getCounter.ts +++ b/02-contract/test/getCounter.ts @@ -2,7 +2,7 @@ import dotenv from "dotenv"; dotenv.config({ path: "../../.env" }); import { getHttpEndpoint } from "@orbs-network/ton-access"; -import { TonClient, Address } from "@ton/ton"; +import { TonClient, Address } from "ton"; import Counter from "./counter.step9"; // this is the interface class we just implemented export async function run() { @@ -21,3 +21,5 @@ export async function run() { //console.log("value:", counterValue.toString()); console.log("value:", counterValue >= 1000000000000n ? "more than 1T" : "less than 1T"); } + +run(); // only for testing purposes diff --git a/02-contract/test/stdlib.fc b/02-contract/test/imports/stdlib.fc similarity index 100% rename from 02-contract/test/stdlib.fc rename to 02-contract/test/imports/stdlib.fc diff --git a/02-contract/test/index.sh b/02-contract/test/index.sh index 0ceb79d..a624efe 100755 --- a/02-contract/test/index.sh +++ b/02-contract/test/index.sh @@ -3,11 +3,11 @@ npm init --yes npm install dotenv npm install ts-node npm install @ton-community/func-js -npm install @ton/ton @ton/core @ton/crypto +npm install ton ton-core ton-crypto npm install @orbs-network/ton-access -npx func-js stdlib.fc counter.fc --boc counter.cell +npx func-js counter.fc --boc counter.cell npx ts-node deploy.step8.ts > deploy.step8.output.txt -COUNTER_ADDRESS=`cut -d : -s -f 2 < deploy.step8.output.txt` npx ts-node step9.ts > step9.output.txt -diff step9.output.txt step9.expected.txt -COUNTER_ADDRESS=`cut -d : -s -f 2 < deploy.step8.output.txt` npx ts-node step10.ts > step10.output.txt -diff step10.output.txt step10.expected.txt \ No newline at end of file +COUNTER_ADDRESS=`cut -d : -s -f 2 < deploy.step8.output.txt` npx ts-node getCounter.ts > getCounter.output.txt +diff getCounter.output.txt getCounter.expected.txt +COUNTER_ADDRESS=`cut -d : -s -f 2 < deploy.step8.output.txt` npx ts-node sendIncrement.ts > sendIncrement.output.txt +diff sendIncrement.output.txt sendIncrement.expected.txt diff --git a/02-contract/test/step10.expected.txt b/02-contract/test/sendIncrement.expected.txt similarity index 100% rename from 02-contract/test/step10.expected.txt rename to 02-contract/test/sendIncrement.expected.txt diff --git a/02-contract/test/sendIncrement.ts b/02-contract/test/sendIncrement.ts index 054c595..ea40c05 100644 --- a/02-contract/test/sendIncrement.ts +++ b/02-contract/test/sendIncrement.ts @@ -2,8 +2,8 @@ import dotenv from "dotenv"; dotenv.config({ path: "../../.env" }); import { getHttpEndpoint } from "@orbs-network/ton-access"; -import { mnemonicToWalletKey } from "@ton/crypto"; -import { TonClient, WalletContractV4, Address } from "@ton/ton"; +import { mnemonicToWalletKey } from "ton-crypto"; +import { TonClient, WalletContractV4, Address } from "ton"; import Counter from "./counter.step10"; // this is the interface class we just implemented export async function run() { @@ -46,3 +46,5 @@ export async function run() { function sleep(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); } + +run(); // only for testing purposes diff --git a/04-testing/test/index.sh b/04-testing/test/index.sh index e6d46cf..a105e47 100755 --- a/04-testing/test/index.sh +++ b/04-testing/test/index.sh @@ -7,4 +7,4 @@ npx jest step2 npx jest step3 npx jest step4 npx jest step5 | grep "#DEBUG#" > step5.output.txt -diff step5.output.txt step5.expected.txt \ No newline at end of file +diff step5.output.txt step5.expected.txt diff --git a/04-testing/test/step3.spec.ts b/04-testing/test/step3.spec.ts index 81e1ff1..d3bd4a2 100644 --- a/04-testing/test/step3.spec.ts +++ b/04-testing/test/step3.spec.ts @@ -2,13 +2,13 @@ import * as fs from "fs"; import { Cell } from "@ton/core"; import { Blockchain, SandboxContract, TreasuryContract } from "@ton/sandbox"; import Counter from "./counter"; // this is the interface class from tutorial 2 -import "@ton-community/test-utils"; // register matchers +import "@ton/test-utils"; // register matchers describe("Counter tests", () => { let blockchain: Blockchain; let wallet1: SandboxContract; let counterContract: SandboxContract; - + beforeEach(async () => { // prepare Counter's initial code and data cells for deployment const counterCode = Cell.fromBoc(fs.readFileSync("counter.cell"))[0]; // compilation output from tutorial 2 @@ -28,4 +28,4 @@ describe("Counter tests", () => { const value = await counterContract.getCounter(); expect(value).toEqual(17n); }); -}); \ No newline at end of file +}); diff --git a/04-testing/test/step4.spec.ts b/04-testing/test/step4.spec.ts index c761b5c..e0349ba 100644 --- a/04-testing/test/step4.spec.ts +++ b/04-testing/test/step4.spec.ts @@ -2,13 +2,13 @@ import * as fs from "fs"; import { Cell } from "@ton/core"; import { Blockchain, SandboxContract, TreasuryContract } from "@ton/sandbox"; import Counter from "./counter"; // this is the interface class from tutorial 2 -import "@ton-community/test-utils"; // register matchers +import "@ton/test-utils"; // register matchers describe("Counter tests", () => { let blockchain: Blockchain; let wallet1: SandboxContract; let counterContract: SandboxContract; - + beforeEach(async () => { // prepare Counter's initial code and data cells for deployment const counterCode = Cell.fromBoc(fs.readFileSync("counter.cell"))[0]; // compilation output from tutorial 2 @@ -34,4 +34,4 @@ describe("Counter tests", () => { const counterValue = await counterContract.getCounter(); expect(counterValue).toEqual(18n); }) -}); \ No newline at end of file +}); diff --git a/04-testing/test/step5.spec.ts b/04-testing/test/step5.spec.ts index 24f0b2b..91f187d 100644 --- a/04-testing/test/step5.spec.ts +++ b/04-testing/test/step5.spec.ts @@ -2,13 +2,13 @@ import * as fs from "fs"; import { Cell, toNano } from "@ton/core"; import { Blockchain, SandboxContract, TreasuryContract } from "@ton/sandbox"; import Counter from "./counter"; // this is the interface class from tutorial 2 -import "@ton-community/test-utils"; // register matchers +import "@ton/test-utils"; // register matchers describe("Counter tests", () => { let blockchain: Blockchain; let wallet1: SandboxContract; let counterContract: SandboxContract; - + beforeEach(async () => { // prepare Counter's initial code and data cells for deployment const counterCode = Cell.fromBoc(fs.readFileSync("counter.debug.cell"))[0]; // version with ~dump instruction @@ -36,4 +36,4 @@ describe("Counter tests", () => { console.log("sending increment message"); await counterContract.sendIncrement(wallet1.getSender()); }) -}); \ No newline at end of file +});