Skip to content

Commit

Permalink
Partially fixed checks
Browse files Browse the repository at this point in the history
  • Loading branch information
krau5 committed Oct 13, 2023
1 parent 6e3aea4 commit 1e2180d
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion 01-wallet/test/tonweb/step7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ async function main() {
console.log("workchain:", walletAddress.wc);
}

main();
main();
8 changes: 4 additions & 4 deletions 02-contract/test/counter.step10.ts
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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) {
Expand All @@ -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)
Expand All @@ -35,4 +35,4 @@ export default class Counter implements Contract {
const { stack } = await provider.get("counter", []);
return stack.readBigNumber();
}
}
}
8 changes: 4 additions & 4 deletions 02-contract/test/counter.step7.ts
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -10,13 +10,13 @@ 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) {
await provider.internal(via, {
value: "0.01", // send 0.01 TON to contract for rent
bounce: false
});
}
}
}
}
8 changes: 4 additions & 4 deletions 02-contract/test/counter.step9.ts
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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) {
Expand All @@ -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();
}
}
}
4 changes: 2 additions & 2 deletions 02-contract/test/deploy.step8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion 02-contract/test/getCounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions 02-contract/test/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
diff step10.output.txt step10.expected.txt
4 changes: 2 additions & 2 deletions 02-contract/test/sendIncrement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion 04-testing/test/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
diff step5.output.txt step5.expected.txt
6 changes: 3 additions & 3 deletions 04-testing/test/step3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TreasuryContract>;
let counterContract: SandboxContract<Counter>;

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
Expand All @@ -28,4 +28,4 @@ describe("Counter tests", () => {
const value = await counterContract.getCounter();
expect(value).toEqual(17n);
});
});
});
6 changes: 3 additions & 3 deletions 04-testing/test/step4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TreasuryContract>;
let counterContract: SandboxContract<Counter>;

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
Expand All @@ -34,4 +34,4 @@ describe("Counter tests", () => {
const counterValue = await counterContract.getCounter();
expect(counterValue).toEqual(18n);
})
});
});
6 changes: 3 additions & 3 deletions 04-testing/test/step5.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TreasuryContract>;
let counterContract: SandboxContract<Counter>;

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
Expand Down Expand Up @@ -36,4 +36,4 @@ describe("Counter tests", () => {
console.log("sending increment message");
await counterContract.sendIncrement(wallet1.getSender());
})
});
});

0 comments on commit 1e2180d

Please sign in to comment.