Lev
2 years ago
5 changed files with 92 additions and 17 deletions
@ -0,0 +1,53 @@ |
|||||||
|
import chai, {assert, expect} from "chai"; |
||||||
|
import chaiBN from "chai-bn"; |
||||||
|
import BN from "bn.js"; |
||||||
|
|
||||||
|
chai.use(chaiBN(BN)); |
||||||
|
|
||||||
|
import {Address, Builder, Cell, contractAddress, Slice} from "ton"; |
||||||
|
import {runContract, SmartContract} from "ton-contract-executor"; |
||||||
|
import * as main from "../contracts/main"; |
||||||
|
import {internalMessage, randomAddress} from "./helpers"; |
||||||
|
|
||||||
|
import {hex as item_code} from "../build/nft-item.compiled.json"; |
||||||
|
import {makeSnakeCell} from "../contracts/utils"; |
||||||
|
import {keyPairFromSeed, KeyPair, sign, keyPairFromSecretKey} from "ton-crypto"; |
||||||
|
import {signBuy} from "../contracts/main"; |
||||||
|
|
||||||
|
let data = main.itemDataUninit({domain: "test", collectionAddress: randomAddress("collection")}); |
||||||
|
|
||||||
|
describe("Creating items tests", () => { |
||||||
|
let contract: SmartContract; |
||||||
|
let debug: boolean = true; |
||||||
|
|
||||||
|
beforeEach(async () => { |
||||||
|
contract = await SmartContract.fromCell( |
||||||
|
Cell.fromBoc(item_code)[0], |
||||||
|
data, |
||||||
|
{debug: debug} |
||||||
|
); |
||||||
|
contract.setC7Config({ |
||||||
|
myself: randomAddress("item") |
||||||
|
}) |
||||||
|
}); |
||||||
|
|
||||||
|
it("allows to set the data", async () => { |
||||||
|
let ownerAddr = randomAddress("dude"); |
||||||
|
const initializeMsg = internalMessage({ |
||||||
|
from: randomAddress("collection"), |
||||||
|
body: main.initializeItemMsg({domain: "test", ownerAddr}), |
||||||
|
value: new BN(0), |
||||||
|
}); |
||||||
|
const res = await contract.sendInternalMessage(initializeMsg); |
||||||
|
expect(res.type).to.equal("success"); |
||||||
|
expect(res.exit_code).to.equal(0); |
||||||
|
const setDataMsg = internalMessage({ |
||||||
|
from: ownerAddr, |
||||||
|
body: main.setContent({domain: "test", zone: "example.ton"}), |
||||||
|
value: new BN(0), |
||||||
|
}) |
||||||
|
const res2 = await contract.sendInternalMessage(setDataMsg); |
||||||
|
expect(res2.type).to.equal("success"); |
||||||
|
expect(res2.exit_code).to.equal(0); |
||||||
|
}); |
||||||
|
}); |
Loading…
Reference in new issue