dev
dart 32 lines 931 Bytes
Raw
1 import 'package:cw_bitcoin/locktime.dart';
2 import 'package:flutter_test/flutter_test.dart';
3
4 void main() {
5 group('antiFeeSnipingLocktime', () {
6 test('returns 0 when not synced', () {
7 expect(antiFeeSnipingLocktime(chainTip: 800000, synced: false), 0);
8 });
9
10 test('returns 0 when chainTip <= 0', () {
11 expect(antiFeeSnipingLocktime(chainTip: 0, synced: true), 0);
12 });
13
14 test('returns the current tip when synced', () {
15 expect(antiFeeSnipingLocktime(chainTip: 800000, synced: true), 800000);
16 });
17 });
18
19 group('locktimeToBytes', () {
20 test('encodes 0 as four zero bytes', () {
21 expect(locktimeToBytes(0), [0, 0, 0, 0]);
22 });
23
24 test('encodes a block height little-endian', () {
25 expect(locktimeToBytes(800000), [0x00, 0x35, 0x0C, 0x00]);
26 });
27
28 test('encodes max 32-bit value', () {
29 expect(locktimeToBytes(0xFFFFFFFF), [0xFF, 0xFF, 0xFF, 0xFF]);
30 });
31 });
32 }