@@ -6,7 +6,8 @@ import { Signer, Program, Wasm, Arg, Args } from './sdk.ts';
66const { is, has } = Test ;
77const { sendSigned, keypair } = await Wasm ( ) ;
88
9- const SIGNER = await Signer ( new Uint8Array ( Array ( 32 ) . fill ( 1 ) ) ) ;
9+ const keypair1 = keypair ( new Uint8Array ( Array ( 32 ) . fill ( 8 ) ) ) ;
10+ const keypair2 = keypair ( new Uint8Array ( Array ( 32 ) . fill ( 9 ) ) ) ;
1011
1112/** Test the SimplicityHL support in Fadroma. */
1213export default Test ( import . meta, 'SimplicityHL' , TestWasm ( ) , TestOnLocalnet ( ) , TestOnTestnet ( ) )
@@ -24,8 +25,8 @@ export function TestWasm() {
2425 has ( 'sendSigned' , is ( 'function' ) , ( sendSigned : Fn ) => {
2526 throws ( ( ) => sendSigned ( ) ) ;
2627 throws ( ( ) => sendSigned ( { } ) ) ;
27- throws ( ( ) => sendSigned ( SIGNER . keypair ) ) ;
28- throws ( ( ) => sendSigned ( SIGNER . keypair , { } ) ) ;
28+ throws ( ( ) => sendSigned ( keypair1 ) ) ;
29+ throws ( ( ) => sendSigned ( keypair2 , { } ) ) ;
2930 } ) ) ;
3031}
3132
@@ -40,7 +41,7 @@ export function TestOnTestnet () {
4041export function TestOnLocalnet ( ) {
4142 // Tests that run on temporary localnet:
4243 return ElementsRegtest . Test ( { } ,
43- Rpc . SendFromWallet ( "100000" , 8 ) , // Fund deployer (non-secret key 8) from genesis wallet
44+ Rpc . SendFromWallet ( "100000" , ElementsRegtest . P2WPKH ( keypair1 . publicKey ( ) ) . address ) ,
4445 TestSend ( ) , // Test the basic transaction primitive
4546 Test ( 'Programs' , // Test SimplicityHL commitment and redemption transactions.
4647 // Empty program, always passes:
@@ -79,10 +80,10 @@ export function TestOnLocalnet () {
7980 argTypes : { PK : "u256" } ,
8081 witTypes : { SIG : "[u8; 64]" } ,
8182 provideArgs : ( ) => ( {
82- PK : Arg . Pubkey ( SIGNER . keypair . xOnlyPublicKey ( ) )
83+ PK : Arg . Pubkey ( keypair1 . xOnlyPublicKey ( ) )
8384 } ) ,
8485 provideWits : ( sighash : Uint8Array < ArrayBufferLike > ) => ( {
85- SIG : Arg . Signature ( SIGNER . keypair . signSchnorr ( sighash ) ) ,
86+ SIG : Arg . Signature ( keypair1 . signSchnorr ( sighash ) ) ,
8687 } ) ,
8788 fee : 2.7e-7 , } ) ) ,
8889 // Shutdown the localnet.
@@ -102,8 +103,6 @@ interface TestSend extends Btc {
102103}
103104
104105function TestSend ( amount = 3000n , fee = 12000n ) {
105- const keypair1 = keypair ( new Uint8Array ( Array ( 32 ) . fill ( 8 ) ) ) ;
106- const keypair2 = keypair ( new Uint8Array ( Array ( 32 ) . fill ( 9 ) ) ) ;
107106 return Fn . Name ( `Test sendSigned ${ amount } for ${ fee } ` , testSend ) ;
108107 async function testSend ( context : TestSend ) {
109108 const { debug = console . debug , rpc, rest, esplora, P2WPKH } = context ;
@@ -185,9 +184,9 @@ function TestProgram (name: string, src: string, {
185184 return Fn . Name ( `${ name } (${ p2tr || 'unspecified P2TR' } )` , testProgram , {
186185 shouldFail, name, src, cost, cmr, p2tr, argTypes, witTypes, provideArgs, provideWits,
187186 } ) ;
188- async function testProgram ( { rpc , rest , ID , ASSETS , P2WPKH } : Btc ) {
187+ async function testProgram ( chain : Btc ) {
189188 // Need chain's genesis hash to compile for the chain.
190- const genesis = await rpc . getblockhash ( 0 ) ;
189+ const genesis = await chain . getBlockHash ( 0 ) ;
191190
192191 // Parameter values are specified by the test case.
193192 // It's a function so they can be made context-dependent,
@@ -205,7 +204,7 @@ function TestProgram (name: string, src: string, {
205204 const id = await rpc . sendtoaddress ( p2tr , String ( 1 ) ) ;
206205
207206 // Create local spender wallet and import it to RPC:
208- const recipient = P2WPKH ( SIGNER . pubEcdsa ) . address ;
207+ const recipient = P2WPKH ( keypair1 . publicKey ( ) ) . address ;
209208 await rpc . importaddress ( recipient ) ;
210209
211210 // Note current balance:
0 commit comments