Skip to content

Commit

Permalink
Remove Test Util (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrysolovay authored Jun 20, 2024
1 parent 06a7226 commit 2ec9dcb
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
cache-dependency-path: package-lock.json
node-version: 21.x
- run: npm ci
- run: npm run build
- run: npm run check
- run: npm run test
81 changes: 28 additions & 53 deletions FungibleToken.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { equal, rejects } from "node:assert"
import { before, describe, it } from "node:test"
import { describe, it } from "node:test"
import {
AccountUpdate,
AccountUpdateForest,
Expand All @@ -16,71 +16,46 @@ import {
UInt64,
UInt8,
} from "o1js"
import { TestPublicKey } from "o1js/dist/node/lib/mina/local-blockchain.js"
import {
FungibleToken,
FungibleTokenAdmin,
FungibleTokenAdminBase,
FungibleTokenAdminDeployProps,
} from "./index.js"
import { newTestPublicKey } from "./test_util.js"

const proofsEnabled = true
const proofsEnabled = process.argv.indexOf("--proofs-disabled") === -1

const localChain = await Mina.LocalBlockchain({
proofsEnabled: proofsEnabled,
proofsEnabled,
enforceTransactionLimits: false,
})
Mina.setActiveInstance(localChain)

describe("token integration", () => {
let deployer: TestPublicKey
let sender: TestPublicKey
let receiver: TestPublicKey
let tokenAdmin: TestPublicKey
let tokenAdminContract: FungibleTokenAdmin
let newTokenAdmin: TestPublicKey
let newTokenAdminContract: FungibleTokenAdmin
let tokenA: TestPublicKey
let tokenAContract: FungibleToken
let tokenBAdmin: TestPublicKey
let tokenBAdminContract: CustomTokenAdmin
let tokenB: TestPublicKey
let tokenBContract: FungibleToken
let thirdPartyA: TestPublicKey
let thirdPartyAContract: ThirdParty
let thirdPartyB: TestPublicKey
let thirdPartyBContract: ThirdParty

before(async () => {
;[deployer, sender, receiver] = localChain.testAccounts

tokenAdmin = newTestPublicKey()
tokenAdminContract = new FungibleTokenAdmin(tokenAdmin)
newTokenAdmin = newTestPublicKey()
newTokenAdminContract = new FungibleTokenAdmin(newTokenAdmin)

tokenA = newTestPublicKey()
tokenAContract = new FungibleToken(tokenA)

tokenBAdmin = newTestPublicKey()
tokenBAdminContract = new CustomTokenAdmin(tokenBAdmin)
tokenB = newTestPublicKey()
tokenBContract = new FungibleToken(tokenB)

thirdPartyA = newTestPublicKey()
thirdPartyAContract = new ThirdParty(thirdPartyA)

thirdPartyB = newTestPublicKey()
thirdPartyBContract = new ThirdParty(thirdPartyB)

if (proofsEnabled) {
await FungibleToken.compile()
await ThirdParty.compile()
await FungibleTokenAdmin.compile()
await CustomTokenAdmin.compile()
}
})
describe("token integration", async () => {
if (proofsEnabled) {
await FungibleToken.compile()
await ThirdParty.compile()
await FungibleTokenAdmin.compile()
await CustomTokenAdmin.compile()
}

const [
tokenAdmin,
newTokenAdmin,
tokenA,
tokenBAdmin,
tokenB,
thirdPartyA,
thirdPartyB,
] = Mina.TestPublicKey.random(7)
const [deployer, sender, receiver] = localChain.testAccounts
const tokenAdminContract = new FungibleTokenAdmin(tokenAdmin)
const newTokenAdminContract = new FungibleTokenAdmin(newTokenAdmin)
const tokenAContract = new FungibleToken(tokenA)
const tokenBAdminContract = new CustomTokenAdmin(tokenBAdmin)
const tokenBContract = new FungibleToken(tokenB)
const thirdPartyAContract = new ThirdParty(thirdPartyA)
const thirdPartyBContract = new ThirdParty(thirdPartyB)

describe("deploy", () => {
it("should deploy token contract A", async () => {
Expand Down
3 changes: 1 addition & 2 deletions examples/e2e.eg.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { equal } from "node:assert"
import { AccountUpdate, Mina, PrivateKey, UInt64, UInt8 } from "o1js"
import { FungibleToken, FungibleTokenAdmin } from "../index.js"
import { TestPublicKeys } from "../test_util.js"

const localChain = await Mina.LocalBlockchain({
proofsEnabled: false,
Expand All @@ -11,7 +10,7 @@ Mina.setActiveInstance(localChain)

const fee = 1e8

const [deployer, owner, alexa, billy] = localChain.testAccounts as TestPublicKeys
const [deployer, owner, alexa, billy] = Mina.TestPublicKey.random(4)
const contract = PrivateKey.randomKeypair()
const admin = PrivateKey.randomKeypair()

Expand Down
3 changes: 1 addition & 2 deletions examples/escrow.eg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
UInt64,
UInt8,
} from "o1js"
import { TestPublicKeys } from "test_util.js"
import { FungibleToken, FungibleTokenAdmin } from "../index.js"

export class TokenEscrow extends SmartContract {
Expand Down Expand Up @@ -54,7 +53,7 @@ Mina.setActiveInstance(localChain)

const fee = 1e8

const [deployer, owner, alexa, billy, jackie] = localChain.testAccounts as TestPublicKeys
const [deployer, owner, alexa, billy, jackie] = Mina.TestPublicKey.random(5)
const tokenContract = PrivateKey.randomKeypair()
const escrowContract = PrivateKey.randomKeypair()
const admin = PrivateKey.randomKeypair()
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"scripts": {
"task": "node --enable-source-maps --no-warnings= --loader ts-node/esm",
"test": "npm run task -- --test FungibleToken.test.ts",
"build": "tsc"
"build": "tsc",
"check": "tsc --noEmit"
},
"peerDependencies": {
"o1js": "^1.1.0"
Expand Down
18 changes: 0 additions & 18 deletions test_util.ts

This file was deleted.

0 comments on commit 2ec9dcb

Please sign in to comment.