Skip to content

Commit 4718604

Browse files
author
Hack.bg R&D
committed
test: simplified localnet test passes
1 parent eca6565 commit 4718604

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function TestOnTestnet () {
5656
export function TestOnLocalnet () {
5757
// Tests that run on temporary localnet:
5858
return ElementsRegtest.Test({},
59-
Rpc.SendFromWallet("100000", ElementsRegtest.P2WPKH(keypair1.publicKey()).address),
59+
Rpc.SendFromWallet("1000000", ElementsRegtest.P2WPKH(keypair1.publicKey()).address),
6060
TestSend(), // Test the basic transaction primitive
6161
Test('Programs', // Test SimplicityHL commitment and redemption transactions.
6262
// Empty program, always passes:
@@ -90,7 +90,7 @@ export function TestOnLocalnet () {
9090
TestProgram("pay to pubkey", `fn main () {
9191
jet::bip_0340_verify((param::PK, jet::sig_all_hash()), witness::SIG)
9292
}`, {
93-
p2tr: 'ert1ppe00tyu7xnl96056wpth5fhas3hesnehglzstluxn77fe9xx2atsaqwx5h',
93+
p2tr: 'ert1pa69jdawgz5wu5uc8ce2cv7lcqf64kadyl4wsrddparl25erfj2vq9824m9',
9494
cmr: 'b1b4447ce3082324635798876f1ae6c9aec9a228eb6e21e3cb991f8970986965',
9595
argTypes: { PK: "u256" },
9696
witTypes: { SIG: "[u8; 64]" },
@@ -153,7 +153,7 @@ function TestProgram (name: string, src: string, {
153153

154154
// Fund program from deployer:
155155
const commitSource = await chain.getUtxo(chain.P2WPKH(keypair1.publicKey()).address);
156-
const commitAmount = BigInt(commitSource.amount * 1e8) - BigInt(fee * 1e8);
156+
const commitAmount = BigInt(Math.floor(commitSource.amount / 100) * 1e8) - BigInt(fee * 1e8);
157157
const commitTxid = await SimplicityHL.Spend() // TODO wrap as program.commit() ?
158158
.asset(commitSource.asset)
159159
.input(commitSource, keypair1)
@@ -164,7 +164,7 @@ function TestProgram (name: string, src: string, {
164164
// Note current recipient balance:
165165
const recipient = chain.P2WPKH(keypair1.publicKey()).address;
166166
const recipientBalance = async (asset = 'bitcoin') =>
167-
BigInt((await chain.getBalance(recipient, 0))[asset] * 1e8);
167+
BigInt(Math.round((await chain.getBalance(recipient, 0))[asset] * 1e8));
168168
const balance = await recipientBalance();
169169

170170
// Find commit (deploy) output = redeem (spend) input:
@@ -176,7 +176,6 @@ function TestProgram (name: string, src: string, {
176176
const utxos = [{ txid, asset, vout: vout.n, address: vout.scriptPubKey.address, amount: vout.value }];
177177

178178
// To get SIGHASH_ALL for signing, first the rest of the transaction must be specified:
179-
180179
const redeemFee = 1e-4;
181180
const redeemAmount = commitAmount - BigInt(redeemFee * 1e8);
182181
const sighashOpts = { asset, utxos, recipient, amount: redeemAmount, fee: redeemFee };

0 commit comments

Comments
 (0)