-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.ts
40 lines (32 loc) · 968 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import type {
InvoiceResponse,
InvoiceBody,
CheckInvoiceBody,
PayInvoiceBody,
} from "./types.ts";
import { post } from "./utils";
async function go() {
const alice = "http://localhost:3001";
const bob = "http://localhost:3002";
const invRes: InvoiceResponse = await post(alice, "invoice", <InvoiceBody>{
amt_msat: 1000000,
});
console.log("invRes", invRes);
const checkRes1 = await post(alice, "check_invoice", <CheckInvoiceBody>{
payment_hash: invRes.payment_hash,
});
console.log("checkRes1", checkRes1);
const payRes = await post(bob, "pay_invoice", <PayInvoiceBody>{
bolt11: invRes.bolt11,
});
console.log("payRes", payRes);
await sleep(500);
const checkRes = await post(alice, "check_invoice", <CheckInvoiceBody>{
payment_hash: invRes.payment_hash,
});
console.log("checkRes", checkRes);
}
go();
export async function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}