TON contracts for Agorata
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
1.8 KiB

import chai, { assert, expect } from "chai";
import chaiBN from "chai-bn";
import BN from "bn.js";
chai.use(chaiBN(BN));
import { Builder, Cell, Slice } from "ton";
import { SmartContract } from "ton-contract-executor";
import * as main from "../contracts/main";
import { internalMessage, randomAddress } from "./helpers";
import { hex } from "../build/main.compiled.json";
import { makeSnakeCell } from "../contracts/utils";
import { signVerify } from "ton-crypto";
describe("Selling tests (instant buy)", () => {
let contract: SmartContract;
let debug: boolean = true;
let keyPair = main.genKeyPair();
beforeEach(async () => {
contract = await SmartContract.fromCell(
Cell.fromBoc(hex)[0],
main.data({
ownerAddress: randomAddress("owner"),
code: Cell.fromBoc(hex)[0],
collectionAddress: randomAddress("collection"),
domain: "alice",
publicKey: keyPair.publicKey
}),
{ debug: debug }
);
});
it("Sell", async () => {
main.setContractBalance(contract, 10 * main.TON());
const sellMessage = internalMessage({
from: randomAddress("buyer"),
body: main.instantBuyMessage({
receiverAddress: randomAddress("buyer"),
issuedCollectionAddr: randomAddress("collection"),
price: 10 * main.TON(),
domain: "bob",
privateKey: keyPair.secretKey
}),
value: new BN(10 * main.TON())
});
context("Public key is correct", async () => {
const pubKeyRes = await contract.invokeGetMethod("get_public_key", []);
expect(pubKeyRes.result[0]).to.equal(keyPair.publicKey);
});
const res = await contract.sendInternalMessage(sellMessage);
expect(res.type).to.equal("success");
expect(res.exit_code).to.equal(0);
});
});