Skip to content

Commit

Permalink
Test CannotSignInput thrown for unsignable input
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewLM committed Aug 18, 2023
1 parent cfd9634 commit c4f2258
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions coinlib/test/tx/transaction_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void main() {
prevOut: examplePrevOut,
publicKey: pubkey,
),
RawInput(prevOut: examplePrevOut, scriptSig: Uint8List(0)),
],
outputs: [],
);
Expand All @@ -251,20 +252,26 @@ void main() {
expect(tx.sign(inputN: 1, key: privkey), isA<Transaction>());

// Input out of range
expect(() => tx.sign(inputN: 2, key: privkey), throwsArgumentError);
expect(() => tx.sign(inputN: 3, key: privkey), throwsArgumentError);

// Wrong key
expect(
() => tx.sign(inputN: 1, key: wrongkey),
throwsA(isA<CannotSignInput>()),
);

// Cannot sign witness input
// Cannot sign witness input without value
expect(
() => tx.sign(inputN: 0, key: privkey),
throwsA(isA<CannotSignInput>()),
);

// Cannot sign raw unmatched input
expect(
() => tx.sign(inputN: 2, key: privkey),
throwsA(isA<CannotSignInput>()),
);

});

test("immutable inputs/outputs", () {
Expand Down

0 comments on commit c4f2258

Please sign in to comment.