Skip to content

Commit

Permalink
Adding more unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
travist committed Feb 14, 2014
1 parent 1b0369b commit b27aafe
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion test/dartminer.dart
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,44 @@ import 'package:unittest/unittest.dart';
import 'package:dartminer/dartminer.dart'; import 'package:dartminer/dartminer.dart';


void main() { void main() {


test('Test byte conversions', () {
expect(byte2LEHex(0x1a), '1a');
expect(halfWord2LEHex(0x1a2b), '2b1a');
expect(word2LEHex(0x1a2b3c4d), '4d3c2b1a');
expect(bigword2LEHex(0x1a2b3c4d5e6f7a8b), '8b7a6f5e4d3c2b1a');
});

test("Double SHA", () {
List<int> input = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122];
List<int> output = [202, 19, 155, 193, 12, 47, 102, 13, 164, 38, 102, 247, 46, 137, 162, 37, 147, 111, 198, 15, 25, 60, 22, 17, 36, 166, 114, 5, 12, 67, 70, 113];
expect(doubleSHA256(input), output);
expect(new String.fromCharCodes(input), 'abcdefghijklmnopqrstuvwxyz');
});

test('Test int2VarIntHex', () {
expect(int2VarIntHex(0x1a), '1a');
expect(int2VarIntHex(0x1a2b), 'fd2b1a');
expect(int2VarIntHex(0x1a2b3c), 'fe3c2b1a00');
expect(int2VarIntHex(0x1a2b3c4d), 'fe4d3c2b1a');
expect(int2VarIntHex(0x1a2b3c4d5e), 'ff5e4d3c2b1a000000');
});

test('Test padNumString', () {
expect(padNumString('', 8), '00000000');
expect(padNumString('234', 8), '00000234');
expect(padNumString('12345678', 8), '12345678');
expect(padNumString('', 4), '0000');
expect(padNumString('12', 4), '0012');
expect(padNumString('1234', 4), '1234');
});

test('Test doubleHash', () {
String input = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2503ef98030400001059124d696e656420627920425443204775696c640800000037000011caffffffff01a0635c95000000001976a91427a1f12771de5cc3b73941664b2537c15316be4388ac00000000';
String output = '05f1f0c7fc25005e7c6e56805130b4d540125a8d09f81ec3da621f99ee5d15c1';
expect(doubleHash(input), output);
});

// Test a mining operation. // Test a mining operation.
test('Test Mining', () { test('Test Mining', () {


Expand Down

0 comments on commit b27aafe

Please sign in to comment.