The tests work
This commit is contained in:
@@ -160,7 +160,7 @@ describe("invitation command - error cases", () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-errors-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -201,7 +201,7 @@ describe("invitation command - receive flow", () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-receive-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -276,7 +276,7 @@ describe("invitation command - receive flow", () => {
|
||||
await handleInvitationCommand(
|
||||
createCommandDeps(app, io, paths),
|
||||
["create", "Wallet (P2PKH)", "receive"],
|
||||
{},
|
||||
{ varTransferredSatoshis: "10000", role: "receiver" },
|
||||
);
|
||||
|
||||
expectLogs(spies, [{ out: "All requirements satisfied" }]);
|
||||
@@ -314,7 +314,7 @@ describe("invitation command - request satoshis flow", () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-request-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -410,7 +410,7 @@ describe("invitation command - send flow with resources", () => {
|
||||
engine = mockEngine.engine;
|
||||
state = mockEngine.state;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-send-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -489,7 +489,7 @@ describe("invitation command - send flow with resources", () => {
|
||||
varRecipientLockingscript:
|
||||
"76a91489abcdefabbaabbaabbaabbaabbaabbaabbaabba88ac",
|
||||
addInput:
|
||||
"0000000000000000000000000000000000000000000000000000000000000000:0",
|
||||
"0000000000000000000000000000000000000000000000000000000000000001:0",
|
||||
role: "sender",
|
||||
},
|
||||
);
|
||||
@@ -536,7 +536,7 @@ describe("invitation command - multi-step append", () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-append-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -684,7 +684,7 @@ describe("invitation command - list and inspect", () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-list-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -853,7 +853,7 @@ describe("invitation command - sign flow", () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-sign-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -930,7 +930,7 @@ describe("invitation command - sign flow", () => {
|
||||
const result = await handleInvitationCommand(
|
||||
createCommandDeps(app, io, paths),
|
||||
["create", "Wallet (P2PKH)", "receive"],
|
||||
{ sign: "true" },
|
||||
{ sign: "true", varTransferredSatoshis: "10000", role: "receiver" },
|
||||
);
|
||||
|
||||
expect(result.invitationIdentifier).toMatch(/^[a-f0-9]{32}$/);
|
||||
@@ -940,6 +940,24 @@ describe("invitation command - sign flow", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests the --sign flag on create will not auto-signs when requirements are not satisfied.
|
||||
*/
|
||||
test("--sign flag auto-signs on create", async () => {
|
||||
const { io, spies } = createMockIO();
|
||||
|
||||
const result = await handleInvitationCommand(
|
||||
createCommandDeps(app, io, paths),
|
||||
["create", "Wallet (P2PKH)", "receive"],
|
||||
{ sign: "true" },
|
||||
);
|
||||
|
||||
expect(result.invitationIdentifier).toMatch(/^[a-f0-9]{32}$/);
|
||||
expectLogs(spies, [
|
||||
{ out: "Remaining requirements" },
|
||||
]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests that signing fails when invitation doesn't exist.
|
||||
*/
|
||||
@@ -969,12 +987,13 @@ describe("invitation command - import flow", () => {
|
||||
let app: AppService;
|
||||
let tempDir: string;
|
||||
let paths: CommandPaths;
|
||||
let mockEngine: any;
|
||||
|
||||
beforeEach(async () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-import-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -1001,7 +1020,7 @@ describe("invitation command - import flow", () => {
|
||||
`inv-${createResult.invitationIdentifier}.json`,
|
||||
);
|
||||
|
||||
const secondApp = await createMockAppService(engine);
|
||||
const secondApp = await createMockAppService(engine, mockEngine.state);
|
||||
const { io: importIO } = createMockIO();
|
||||
|
||||
const importResult = await handleInvitationCommand(
|
||||
@@ -1048,7 +1067,7 @@ describe("invitation command - import flow", () => {
|
||||
`inv-${createResult.invitationIdentifier}.json`,
|
||||
);
|
||||
|
||||
const secondApp = await createMockAppService(engine);
|
||||
const secondApp = await createMockAppService(engine, mockEngine.state);
|
||||
const { io: importIO } = createMockIO();
|
||||
|
||||
await handleInvitationCommand(
|
||||
@@ -1077,7 +1096,7 @@ describe("invitation command - import flow", () => {
|
||||
`inv-${createResult.invitationIdentifier}.json`,
|
||||
);
|
||||
|
||||
const secondApp = await createMockAppService(engine);
|
||||
const secondApp = await createMockAppService(engine, mockEngine.state);
|
||||
const { io: importIO } = createMockIO();
|
||||
|
||||
await handleInvitationCommand(
|
||||
@@ -1106,7 +1125,7 @@ describe("invitation command - auto-inputs flow", () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-autoinputs-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -1182,7 +1201,7 @@ describe("invitation command - broadcast flow", () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-broadcast-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -1247,7 +1266,7 @@ describe("invitation command - full lifecycle", () => {
|
||||
const mockEngine = await createMockEngine(DEFAULT_SEED);
|
||||
engine = mockEngine.engine;
|
||||
await engine.importTemplate(p2pkhTemplate);
|
||||
app = await createMockAppService(engine);
|
||||
app = await createMockAppService(engine, mockEngine.state);
|
||||
tempDir = mkdtempSync(path.join(tmpdir(), "xo-cli-invitation-lifecycle-"));
|
||||
paths = createMockPaths(tempDir);
|
||||
});
|
||||
@@ -1402,7 +1421,7 @@ describe("invitation command - full lifecycle", () => {
|
||||
const result = await handleInvitationCommand(
|
||||
createCommandDeps(app, io, paths),
|
||||
["create", "Wallet (P2PKH)", "receive"],
|
||||
{ sign: "true" },
|
||||
{ sign: "true", varTransferredSatoshis: "10000", role: "receiver" },
|
||||
);
|
||||
|
||||
expect(result.invitationIdentifier).toMatch(/^[a-f0-9]{32}$/);
|
||||
|
||||
Reference in New Issue
Block a user