Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
No fee inconsistency when building transaction either
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewLM committed Dec 9, 2021
1 parent c60affb commit 6f95f62
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion test/transaction_size_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'package:coinslib/src/ecpair.dart';
import 'package:coinslib/src/transaction_builder.dart';
import 'package:test/test.dart';
import '../lib/src/transaction.dart';
import 'package:coinslib/src/transaction.dart';
import 'package:coinslib/src/models/networks.dart' as NETWORKS;

main() {

Expand Down Expand Up @@ -32,6 +35,38 @@ main() {

});

test('built tranasaction gives correct size', () {

// Peercoin WIF format
final aliceKey = ECPair.fromWIF(
'U9ofQxewXjF48KW7J5zd5FhnC3oCYsj15ESMtUvJnsfbjEDN43aW',
network: NETWORKS.peercoin
);

final txb = new TransactionBuilder(network: NETWORKS.peercoin);

txb.setVersion(3);
txb.addInput(
'61d520ccb74288c96bc1a2b20ea1c0d5a704776dd0164a396efec3ea7040349d',
0
);

txb.addOutput('P8gWEwpDSPPohHMHcNA5cg7di7pgRrXGGk', 12000);
// Do null outputs break it?
txb.addNullOutput('Hey this is a random string without coins');

txb.sign(vin: 0, keyPair: aliceKey);

final tx = txb.build();

print(tx.txSize);
// No witness data so size should equal buffer size
expect(tx.txSize, tx.toBuffer().length);
// Deterministically 244 bytes each time
expect(tx.txSize, 244);

});

});

}

0 comments on commit 6f95f62

Please sign in to comment.