Skip to content

Commit

Permalink
Replace compile to loadArtifact
Browse files Browse the repository at this point in the history
  • Loading branch information
gitzhou committed Sep 4, 2023
1 parent 83c1483 commit ed84d0f
Show file tree
Hide file tree
Showing 54 changed files with 93 additions and 97 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"scrypt-ts": "^1.3.5",
"scrypt-ts": "^1.3.6",
"scrypt-ts-lib": "^0.1.20"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tests/accumulatorMultiSig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let accumulatorMultiSig: AccumulatorMultiSig

describe('Test SmartContract `AccumulatorMultiSig`', () => {
before(async () => {
await AccumulatorMultiSig.compile()
AccumulatorMultiSig.loadArtifact()
accumulatorMultiSig = new AccumulatorMultiSig(2n, pubKeyHashes)

const signer = getDefaultSigner([privateKey1, privateKey2, privateKey3])
Expand Down
2 changes: 1 addition & 1 deletion tests/ackermann.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Test SmartContract `Ackermann`', () => {
let ackermann: Ackermann

before(async () => {
await Ackermann.compile()
Ackermann.loadArtifact()
ackermann = new Ackermann(2n, 1n)

await ackermann.connect(getDefaultSigner())
Expand Down
4 changes: 2 additions & 2 deletions tests/advancedCounter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { getDefaultSigner } from './utils/helper'
import { MethodCallOptions } from 'scrypt-ts'

describe('Test SmartContract `AdvancedCounter`', () => {
before(async () => {
await AdvancedCounter.compile()
before(() => {
AdvancedCounter.loadArtifact()
})

it('should pass the public method unit test successfully.', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/asm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Test SmartContract `P2PKH_ASM`', () => {
let demo: P2PKH_ASM

before(async () => {
await P2PKH_ASM.compile()
P2PKH_ASM.loadArtifact()

demo = new P2PKH_ASM(PubKeyHash(toHex(myPublicKeyHash)))
await demo.connect(getDefaultSigner())
Expand Down
2 changes: 1 addition & 1 deletion tests/auction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Test SmartContract `Auction` on testnet', () => {
let auction: Auction

before(async () => {
await Auction.compile()
Auction.loadArtifact()

auction = new Auction(
PubKey(toHex(publicKeyAuctioneer)),
Expand Down
4 changes: 2 additions & 2 deletions tests/blindEscrow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Heavy: Test SmartContract `BlindEscrow`', () => {

let blindEscrow: BlindEscrow

before(async () => {
before(() => {
seller = bsv.PrivateKey.fromRandom(bsv.Networks.testnet)
buyer = bsv.PrivateKey.fromRandom(bsv.Networks.testnet)
arbiter = bsv.PrivateKey.fromRandom(bsv.Networks.testnet)
Expand All @@ -57,7 +57,7 @@ describe('Heavy: Test SmartContract `BlindEscrow`', () => {

escrowNonce = toByteString('001122334455aabbcc') // TODO

await BlindEscrow.compile()
BlindEscrow.loadArtifact()

blindEscrow = new BlindEscrow(
sellerPKH,
Expand Down
2 changes: 1 addition & 1 deletion tests/bsv20Auction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async function deployInscription(
}

async function main() {
await BSV20Auction.compile()
BSV20Auction.loadArtifact()

const privateKeyAuctioneer = myPrivateKey
const publicKeyAuctioneer = myPublicKey
Expand Down
5 changes: 2 additions & 3 deletions tests/catastropheBond.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ describe('Test SmartContract `CatBond`', () => {
typeof CatBond.MAX_INVESTORS
>

before(async () => {
// Compile contract.
await CatBond.compile()
before(() => {
CatBond.loadArtifact()
})

it('should pass invest and payout', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/clone.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { getDefaultSigner } from './utils/helper'
import { MethodCallOptions } from 'scrypt-ts'

describe('Test SmartContract `Clone`', () => {
before(async () => {
await Clone.compile()
before(() => {
Clone.loadArtifact()
})

it('should pass the public method unit test successfully.', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/cointoss.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Test SmartContract `Cointoss`', () => {
const [aliceprivatekey, alicepublickey] = randomPrivateKey()
const [bobprivatekey, bobpublickey] = randomPrivateKey()
before(async () => {
await CoinToss.compile()
CoinToss.loadArtifact()
instance = new CoinToss(
PubKey(toHex(alicepublickey)),
PubKey(toHex(bobpublickey)),
Expand Down
4 changes: 2 additions & 2 deletions tests/counter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { getDefaultSigner } from './utils/helper'
import { MethodCallOptions } from 'scrypt-ts'

describe('Test SmartContract `Counter`', () => {
before(async () => {
await Counter.compile()
before(() => {
Counter.loadArtifact()
})

it('should pass the public method unit test successfully.', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/counter2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { getDefaultSigner } from './utils/helper'
import { MethodCallOptions } from 'scrypt-ts'

describe('Test SmartContract `Counter`', () => {
before(async () => {
await Counter2.compile()
before(() => {
Counter2.loadArtifact()
})

it('should pass the public method increment test successfully.', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/crossChainSwap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('Test SmartContract `CrossChainSwap`', () => {
)
const xHash = sha256(x)

before(async () => {
await CrossChainSwap.compile()
before(() => {
CrossChainSwap.loadArtifact()

crossChainSwap = new CrossChainSwap(
PubKey(alicePubKey.toHex()),
Expand Down
4 changes: 2 additions & 2 deletions tests/crossChainSwap2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ describe('Test SmartContract `CrossChainSwap2`', () => {
},
]

before(async () => {
await CrossChainSwap2.compile()
before(() => {
CrossChainSwap2.loadArtifact()

crossChainSwap = new CrossChainSwap2(
Ripemd160(aliceAddr),
Expand Down
2 changes: 1 addition & 1 deletion tests/crowdfund.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Test SmartContract `Crowdfund`', () => {
let crowdfund: Crowdfund

before(async () => {
await Crowdfund.compile()
Crowdfund.loadArtifact()
crowdfund = new Crowdfund(
PubKey(toHex(publicKeyRecipient)),
PubKey(toHex(publicKeyContributor)),
Expand Down
2 changes: 1 addition & 1 deletion tests/demo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Test SmartContract `Demo`', () => {
let demo: Demo

before(async () => {
await Demo.compile()
Demo.loadArtifact()

demo = new Demo(-2n, 7n)
await demo.connect(getDefaultSigner())
Expand Down
4 changes: 2 additions & 2 deletions tests/enforceRecipient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { myPublicKeyHash } from './utils/privateKey'
import { getDefaultSigner } from './utils/helper'

describe('Test SmartContract `EnforceRecipient`', () => {
before(async () => {
await EnforceRecipient.compile()
before(() => {
EnforceRecipient.loadArtifact()
})

it('should transpile contract `EnforceRecipient` successfully.', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/erc20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const initialSupply = 1000000n
describe('Test SmartContract `ERC20`', () => {
let map: BalanceMap, allowances: AllowanceMap, erc20: ERC20
before(async () => {
await ERC20.compile()
ERC20.loadArtifact()

map = new HashedMap<PubKeyHash, bigint>()
allowances = new HashedMap<Allowance, bigint>()
Expand Down
4 changes: 2 additions & 2 deletions tests/erc721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { getDefaultSigner, randomPrivateKey } from './utils/helper'

use(chaiAsPromised)
describe('Test SmartContract `Erc721`', () => {
before(async () => {
await Erc721.compile()
before(() => {
Erc721.loadArtifact()
})

it('should fail `mint` without correct minter sig', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/hashPuzzle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const byteString = toByteString(plainText, true)
const sha256Data = sha256(byteString)

describe('Test SmartContract `HashPuzzle`', () => {
before(async () => {
await HashPuzzle.compile()
before(() => {
HashPuzzle.loadArtifact()
})

it('should pass the public method unit test successfully.', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/hashedMapNonState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { getDefaultSigner } from './utils/helper'
use(chaiAsPromised)

describe('Test SmartContract `HashedMapNonState`', () => {
before(async () => {
await HashedMapNonState.compile()
before(() => {
HashedMapNonState.loadArtifact()
})

it('should unlock `HashedMapNonState` successfully.', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/hashedMapState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getDefaultSigner } from './utils/helper'
describe('Test SmartContract `HashedMapState`', () => {
let map: HashedMap<bigint, ByteString>, stateMap: HashedMapState
before(async () => {
await HashedMapState.compile()
HashedMapState.loadArtifact()

map = new HashedMap<bigint, ByteString>()

Expand Down
4 changes: 2 additions & 2 deletions tests/hashedSetNonState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import chaiAsPromised from 'chai-as-promised'
use(chaiAsPromised)

describe('Test SmartContract `HashedSetNonState`', () => {
before(async () => {
await HashedSetNonState.compile()
before(() => {
HashedSetNonState.loadArtifact()
})

it('should unlock contract `HashedSetNonState` successfully.', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/hashedSetState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getDefaultSigner } from './utils/helper'
describe('Test SmartContract `HashedSetState`', () => {
let set: HashedSet<bigint>, stateSet: HashedSetState
before(async () => {
await HashedSetState.compile()
HashedSetState.loadArtifact()

set = new HashedSet<bigint>()

Expand Down
2 changes: 1 addition & 1 deletion tests/helloWorld.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Test SmartContract `HelloWorld`', () => {
let helloWorld: HelloWorld

before(async () => {
await HelloWorld.compile()
HelloWorld.loadArtifact()
helloWorld = new HelloWorld(sha256(toByteString('hello world', true)))
await helloWorld.connect(getDefaultSigner())
})
Expand Down
8 changes: 3 additions & 5 deletions tests/library.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use(chaiAsPromised)

describe('Test SmartContract `Test`', () => {
let instance: Test
let l = new L(2n, 3n)
const l = new L(2n, 3n)

before(async () => {
await Test.compile()
Test.loadArtifact()
instance = new Test(2n, l)
await instance.connect(getDefaultSigner())
})
Expand All @@ -20,9 +20,7 @@ describe('Test SmartContract `Test`', () => {
console.log(' Library Test contract deployed: ', deployTx.id)

const callContract = async () => {
await instance.methods.unlock(
3n
)
await instance.methods.unlock(3n)
expect(callContract()).not.throw
}
})
Expand Down
12 changes: 6 additions & 6 deletions tests/matrix.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Matrix } from '../src/contracts/matrix'
import { getDefaultSigner} from './utils/helper'
import { getDefaultSigner } from './utils/helper'

import { expect } from 'chai'

async function main() {
await Matrix.compile()
Matrix.loadArtifact()

// const [privateKeyalice, publicKeyalice] = randomPrivateKey()
// const [privateKeybob, publicKeybob] = randomPrivateKey()
Expand All @@ -17,10 +17,10 @@ async function main() {

const callContract = async () => {
await instance.methods.main([
[1n, 1n, 1n, 1n],
[2n, 2n, 2n, 2n],
[3n, 3n, 3n, 3n],
[4n, 4n, 4n, 4n]
[1n, 1n, 1n, 1n],
[2n, 2n, 2n, 2n],
[3n, 3n, 3n, 3n],
[4n, 4n, 4n, 4n],
])
expect(callContract()).not.Throw
}
Expand Down
4 changes: 2 additions & 2 deletions tests/mimc7.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Mimc7Test } from '../src/contracts/mimc7'
import { getDefaultSigner } from './utils/helper'

describe('Test SmartContract `Mimc7Test`', () => {
before(async () => {
await Mimc7Test.compile()
before(() => {
Mimc7Test.loadArtifact()
})

it('should pass the public method unit test successfully.', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/modEXP.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use(chaiAsPromised)
describe('Test SmartContract `modEXP`', () => {
let instance: ModExp
before(async () => {
await ModExp.compile()
ModExp.loadArtifact()

instance = new ModExp(13n)
await instance.connect(getDefaultSigner())
Expand Down
2 changes: 1 addition & 1 deletion tests/multiPartyHashPuzzle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Test SmartContract `MultiPartyHashPuzzle`', () => {
>
hashes = _hashes as FixedArray<Sha256, typeof MultiPartyHashPuzzle.N>

await MultiPartyHashPuzzle.compile()
MultiPartyHashPuzzle.loadArtifact()
instance = new MultiPartyHashPuzzle(hashes)

await instance.connect(getDefaultSigner())
Expand Down
2 changes: 1 addition & 1 deletion tests/multiPartyHashPuzzleOpt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Test SmartContract `MultiPartyHashPuzzleOpt`', () => {
typeof MultiPartyHashPuzzleOpt.N
>

await MultiPartyHashPuzzleOpt.compile()
MultiPartyHashPuzzleOpt.loadArtifact()
instance = new MultiPartyHashPuzzleOpt(combinedHash)

await instance.connect(getDefaultSigner())
Expand Down
Loading

0 comments on commit ed84d0f

Please sign in to comment.