Created
May 17, 2023 12:51
-
-
Save gitzhou/b685bdaf7c47eaa752c5c335f5c82f22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MethodCallOptions, PubKey, PubKeyHash, toHex } from 'scrypt-ts' | |
import { Pyramid } from '../../src/contracts/pyramid' | |
import { | |
getDummySigner, | |
getDummyUTXO, | |
randomPrivateKey, | |
} from '../utils/txHelper' | |
import { myPublicKeyHash, myAddress } from '../utils/privateKey' | |
import { expect } from 'chai' | |
async function main() { | |
await Pyramid.compile() | |
const pyramid = new Pyramid(PubKeyHash(toHex(myPublicKeyHash)), 1000n) | |
pyramid.bindTxBuilder('recruit', Pyramid.recruitTxBuilder) | |
await pyramid.connect(getDummySigner()) | |
const [, alicePubKey, ,] = randomPrivateKey() | |
const [, bobPubKey, ,] = randomPrivateKey() | |
const aliceInstance = pyramid.next() | |
aliceInstance.schemer = PubKeyHash(toHex(alicePubKey)) | |
const bobInstance = pyramid.next() | |
bobInstance.schemer = PubKeyHash(toHex(bobPubKey)) | |
const { tx: callTx, atInputIndex } = await pyramid.methods.recruit( | |
PubKey(toHex(alicePubKey)), | |
PubKey(toHex(bobPubKey)), | |
{ | |
fromUTXO: getDummyUTXO(), | |
changeAddress: myAddress, | |
} as MethodCallOptions<Pyramid> | |
) | |
const result = callTx.verifyScript(atInputIndex) | |
expect(result.success, result.error).to.eq(true) | |
} | |
describe('Test SmartContract Pyramid unit test', () => { | |
it('should succeed', async () => { | |
await main() | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment