Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

tests: re-enable all tests #155

Merged
merged 2 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ops/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ services:
L1_NODE_WEB3_URL: http://l1_chain:8545
L2_NODE_WEB3_URL: http://l2geth:8545
URL: http://deployer:8081/addresses.json
WHITELIST_ENDPOINT: http://omgx_bl-wl:9000/whitelist.json
# a funded hardhat account
L1_WALLET_KEY: '0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97'
RETRIES: 60
Expand Down
153 changes: 97 additions & 56 deletions packages/omgx/contracts/test/b_nft.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,62 +12,103 @@ import * as fs from 'fs'

describe('NFT Test\n', async () => {

it('should mint an ERC721 and transfer it from Bob to Alice', async () => {

// const owner = env.bobl2Wallet.address;
// const recipient = env.alicel2Wallet.address;
// const ownerName = "Henrietta Lacks"

// let meta = ownerName + '#' + Date.now().toString() + '#' + 'https://www.atcc.org/products/all/CCL-2.aspx';
// console.log(` ⚽️ ${chalk.red(`meta:`)} ${chalk.green(`${meta}`)}`)

// //mint one NFT
// let nft = await L2ERC721.mintNFT(
// recipient,
// meta,
// {gasLimit: 800000, gasPrice: 0}
// )
// await nft.wait()
// // console.log("ERC721:",nft)

// const balanceOwner = await L2ERC721.balanceOf(owner)
// const balanceRecipient = await L2ERC721.balanceOf(recipient)

// console.log(` ⚽️ ${chalk.red(`balanceOwner:`)} ${chalk.green(`${balanceOwner.toString()}`)}`)
// console.log(` ⚽️ ${chalk.red(`balanceRecipient:`)} ${chalk.green(`${balanceRecipient.toString()}`)}`)

// //Get the URL
// let nftURL = await L2ERC721.getTokenURI(
// BigNumber.from(String(0)),
// {gasLimit: 800000, gasPrice: 0}
// )
// console.log(` ⚽️ ${chalk.red(`nftURL:`)} ${chalk.green(`${nftURL}`)}`)

// //Should be 1
// let TID = await L2ERC721.getLastTID({gasLimit: 800000, gasPrice: 0})
// console.log(` ⚽️ ${chalk.red(`TID:`)} ${chalk.green(`${TID.toString()}`)}`)

// //mint a second NFT
// meta = ownerName + '#' + Date.now().toString() + '#' + 'https://www.atcc.org/products/all/CCL-185.aspx';
// nft = await L2ERC721.mintNFT(
// recipient,
// meta,
// {gasLimit: 800000, gasPrice: 0}
// )
// await nft.wait()

// //Should be 2
// TID = await L2ERC721.getLastTID({ gasLimit: 800000, gasPrice: 0 })
// console.log(` ⚽️ ${chalk.red(`TID:`)} ${chalk.green(`${TID.toString()}`)}`)

// //it('returns the amount of tokens owned by the given address', async function () {
// expect(await L2ERC721.balanceOf(owner)).to.deep.eq(BigNumber.from(String(0)));

// // Token 1 should be owned by recipient
// expect(await L2ERC721.ownerOf(BigNumber.from(String(1)))).to.deep.eq(recipient);

// //And Token 50 should not exist (at this point)
// expect(L2ERC721.ownerOf(BigNumber.from(String(50)))).to.be.eventually.rejectedWith("ERC721: owner query for nonexistent token");
let Factory__L2ERC721: ContractFactory
let L2ERC721: Contract

let env: OptimismEnv

const nftName = 'TestNFT'
const nftSymbol = 'TST'

/************* BOB owns all the pools, and ALICE Mints a new token ***********/
before(async () => {

env = await OptimismEnv.new()

Factory__L2ERC721 = new ContractFactory(
L2ERC721Json.abi,
L2ERC721Json.bytecode,
env.bobl2Wallet
)

})

before(async () => {

// Mint a new NFT on L2
// [nftSymbol, nftName]
// this is owned by bobl1Wallet
L2ERC721 = await Factory__L2ERC721.deploy(
nftSymbol,
nftName,
BigNumber.from(String(0)), //starting index for the tokenIDs
"", //the base URI is empty in this case
{gasLimit: 800000, gasPrice: 0}
)
await L2ERC721.deployTransaction.wait()
console.log(` 🌕 ${chalk.red('NFT L2ERC721 deployed to:')} ${chalk.green(L2ERC721.address)}`)

let owner = await L2ERC721.owner()
console.log(` 🔒 ${chalk.red('ERC721 owner:')} ${chalk.green(owner)}`)
})

it('should mint a new ERC721 and transfer it from Bob to Alice', async () => {

const owner = env.bobl2Wallet.address;
const recipient = env.alicel2Wallet.address;
const ownerName = "Henrietta Lacks"

let meta = ownerName + '#' + Date.now().toString() + '#' + 'https://www.atcc.org/products/all/CCL-2.aspx';
console.log(` ⚽️ ${chalk.red(`meta:`)} ${chalk.green(`${meta}`)}`)

//mint one NFT
let nft = await L2ERC721.mintNFT(
recipient,
meta,
{gasLimit: 800000, gasPrice: 0}
)
await nft.wait()
// console.log("ERC721:",nft)

const balanceOwner = await L2ERC721.balanceOf(owner)
const balanceRecipient = await L2ERC721.balanceOf(recipient)

console.log(` ⚽️ ${chalk.red(`balanceOwner:`)} ${chalk.green(`${balanceOwner.toString()}`)}`)
console.log(` ⚽️ ${chalk.red(`balanceRecipient:`)} ${chalk.green(`${balanceRecipient.toString()}`)}`)

//Get the URL
let nftURL = await L2ERC721.getTokenURI(
BigNumber.from(String(0)),
{gasLimit: 800000, gasPrice: 0}
)
console.log(` ⚽️ ${chalk.red(`nftURL:`)} ${chalk.green(`${nftURL}`)}`)

//Should be 1
let TID = await L2ERC721.getLastTID({gasLimit: 800000, gasPrice: 0})
console.log(` ⚽️ ${chalk.red(`TID:`)} ${chalk.green(`${TID.toString()}`)}`)

//mint a second NFT
meta = ownerName + '#' + Date.now().toString() + '#' + 'https://www.atcc.org/products/all/CCL-185.aspx';
nft = await L2ERC721.mintNFT(
recipient,
meta,
{gasLimit: 800000, gasPrice: 0}
)
await nft.wait()

//Should be 2
TID = await L2ERC721.getLastTID({ gasLimit: 800000, gasPrice: 0 })
console.log(` ⚽️ ${chalk.red(`TID:`)} ${chalk.green(`${TID.toString()}`)}`)

//it('returns the amount of tokens owned by the given address', async function () {
expect(await L2ERC721.balanceOf(owner)).to.deep.eq(BigNumber.from(String(0)));
//});

// Token 1 should be owned by recipient
expect(await L2ERC721.ownerOf(BigNumber.from(String(1)))).to.deep.eq(recipient);

//And Token 50 should not exist (at this point)
expect(L2ERC721.ownerOf(BigNumber.from(String(50)))).to.be.eventually.rejectedWith("ERC721: owner query for nonexistent token");
})

})
Loading