-
Notifications
You must be signed in to change notification settings - Fork 0
feat: contract integration test #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
662052d
contract test; fixes
sczembor 01ee6e7
Update packages/btcindexer/src/sui-client.ts
sczembor 4772f35
Apply suggestions from code review
sczembor 4d163ac
disable linter
sczembor 7bbca8e
add dotenv
sczembor 28c0e94
remove unsued dotenv
sczembor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import "dotenv/config"; | ||
| import { describe, it, assert } from "vitest"; | ||
| import { Indexer } from "./btcindexer"; | ||
| import { SuiClient, SuiClientConfig } from "./sui-client"; | ||
| import { Block, networks } from "bitcoinjs-lib"; | ||
|
|
||
| const REGTEST_DATA = { | ||
| BLOCK_HEX: | ||
| "000000305c2f30d99ad69f247638613dcca7f455159e252878ea6fe10bbc4574a0076914d98ada655d950ac6507d14584fa679d12fb5203c384e52ef292d063fe29b1b645c4b6d68ffff7f200200000002020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff04022f0100ffffffff02de82814a0000000016001477174bfb906c0e52d750eac4b40fd86746ad50550000000000000000266a24aa21a9ed27611410788b35b819e10a0227f40f9bbc70df824e3a30879552f004b48451210120000000000000000000000000000000000000000000000000000000000000000000000000020000000001017fec0755f3524b89ad45383343f992a0d5cb797a695b59e30f2fc80794f001050000000000fdffffff032202089200000000160014b125723e78c2d779e3e299dfd95d72e9a067a0b780f0fa02000000001600144cc99479ada301056d78a8f3676cfb404d696abe00000000000000000d6a0b3078313233343536373839024730440220755610ff6b6fdea530c20d11b7765816beb75e16ce78fa200a7da25e251a7eb9022078e78bed1cc38822cd5dce3982e23c3cd401415ae72050b00c5f8b3441a2c178012103ef55b72bddf4960ddbb12a9a04f61f91fb613aa99b472115f25a5f8686e6c3f200000000", | ||
| TX_ID: "2060dfd3cdbffb7db6c968357f3c9df91b52a4cef5c02fad0b0836b0f25cc4ca", | ||
| BLOCK_HEIGHT: 303, | ||
| }; | ||
|
|
||
| const SUI_CLIENT_CONFIG: SuiClientConfig = { | ||
| suiNetwork: "devnet", | ||
| suiPackageId: "0x7a03af034ade1d5b4072ba4fdb9650bd5ce0cd4dcab40f0563540be0ebbe824b", | ||
| suiModule: "indexer_test", | ||
| suiFunction: "mint", | ||
| suiNbtcObjectId: "0xd93cc7f6d91100990f9fa8ca11d533a69254e2f716ab69a22c6cc4e9a49a9374", | ||
| suiLightClientObjectId: | ||
| "0xd93cc7f6d91100990f9fa8ca11d533a69254e2f716ab69a22c6cc4e9a49a9374", | ||
| suiSignerMnemonic: | ||
| "april tonight combine album kit burst detect outside label quiz undo such", | ||
| }; | ||
|
|
||
| // NOTE: skip to prevent this test from running in CI | ||
| describe.skip("Sui Contract Integration", () => { | ||
| it("should successfully call the mint function on devnet", { timeout: 60000 }, async () => { | ||
| const suiClient = new SuiClient(SUI_CLIENT_CONFIG); | ||
| const indexer = new Indexer( | ||
| {} as any, | ||
| "bcrt1qfnyeg7dd5vqs2mtc4rekwm8mgpxkj647p39zhw", | ||
| "fallback", | ||
| networks.regtest, | ||
| suiClient, | ||
| ); | ||
| const block = Block.fromHex(REGTEST_DATA.BLOCK_HEX); | ||
| const txIndex = block.transactions?.findIndex( | ||
| (tx) => tx.getId() === REGTEST_DATA.TX_ID, | ||
| ); | ||
| assert(txIndex); | ||
| const targetTx = block.transactions?.[txIndex ?? -1]; | ||
| assert(targetTx); | ||
|
|
||
| const tree = indexer.constructMerkleTree(block); | ||
| assert(tree); | ||
| const proofResult = indexer.getTxProof(tree, targetTx); | ||
| assert(proofResult); | ||
|
|
||
| const success = await suiClient.tryMintNbtc( | ||
| targetTx, | ||
| REGTEST_DATA.BLOCK_HEIGHT, | ||
| txIndex, | ||
| proofResult, | ||
| ); | ||
| assert.isTrue(success); | ||
| }); | ||
| }); | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.