|
| 1 | +import 'package:bitcoin_base/bitcoin_base.dart'; |
| 2 | +import 'package:test/test.dart'; |
| 3 | + |
| 4 | +void main() { |
| 5 | + group('BitcoinTransactionBuilder locktime', () { |
| 6 | + test('defaults to defaultTxLocktime', () { |
| 7 | + final b = BitcoinTransactionBuilder( |
| 8 | + outPuts: const [], |
| 9 | + fee: BigInt.zero, |
| 10 | + network: BitcoinNetwork.mainnet, |
| 11 | + utxos: const [], |
| 12 | + ); |
| 13 | + expect(b.locktime, BitcoinOpCodeConst.defaultTxLocktime); |
| 14 | + }); |
| 15 | + |
| 16 | + test('stores the provided locktime', () { |
| 17 | + final lt = [0x50, 0x01, 0xcf, 0x00]; |
| 18 | + final b = BitcoinTransactionBuilder( |
| 19 | + outPuts: const [], |
| 20 | + fee: BigInt.zero, |
| 21 | + network: BitcoinNetwork.mainnet, |
| 22 | + utxos: const [], |
| 23 | + locktime: lt, |
| 24 | + ); |
| 25 | + expect(b.locktime, lt); |
| 26 | + }); |
| 27 | + }); |
| 28 | + |
| 29 | + group('ForkedTransactionBuilder locktime', () { |
| 30 | + test('defaults to defaultTxLocktime', () { |
| 31 | + final b = ForkedTransactionBuilder( |
| 32 | + outPuts: const [], |
| 33 | + fee: BigInt.zero, |
| 34 | + network: BitcoinCashNetwork.mainnet, |
| 35 | + utxos: const [], |
| 36 | + ); |
| 37 | + expect(b.locktime, BitcoinOpCodeConst.defaultTxLocktime); |
| 38 | + }); |
| 39 | + |
| 40 | + test('stores the provided locktime', () { |
| 41 | + final lt = [0x50, 0x01, 0xcf, 0x00]; |
| 42 | + final b = ForkedTransactionBuilder( |
| 43 | + outPuts: const [], |
| 44 | + fee: BigInt.zero, |
| 45 | + network: BitcoinCashNetwork.mainnet, |
| 46 | + utxos: const [], |
| 47 | + locktime: lt, |
| 48 | + ); |
| 49 | + expect(b.locktime, lt); |
| 50 | + }); |
| 51 | + }); |
| 52 | +} |
0 commit comments