forked from wakiyamap/ltc-scrypt
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.py
48 lines (40 loc) · 2.39 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright (C) 2022 Free Software Foundation, Inc. <http://fsf.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import ltc_scrypt
INPUT = [
"020000004c1271c211717198227392b029a64a7971931d351b387bb80db027f270411e398a07046f7d4a08dd815412a8712f874a7ebf0507e3878bd24e20a3b73fd750a667d2f451eac7471b00de6659",
"0200000011503ee6a855e900c00cfdd98f5f55fffeaee9b6bf55bea9b852d9de2ce35828e204eef76acfd36949ae56d1fbe81c1ac9c0209e6331ad56414f9072506a77f8c6faf551eac7471b00389d01",
"02000000a72c8a177f523946f42f22c3e86b8023221b4105e8007e59e81f6beb013e29aaf635295cb9ac966213fb56e046dc71df5b3f7f67ceaeab24038e743f883aff1aaafaf551eac7471b0166249b",
"010000007824bc3a8a1b4628485eee3024abd8626721f7f870f8ad4d2f33a27155167f6a4009d1285049603888fe85a84b6c803a53305a8d497965a5e896e1a00568359589faf551eac7471b0065434e",
"0200000050bfd4e4a307a8cb6ef4aef69abc5c0f2d579648bd80d7733e1ccc3fbc90ed664a7f74006cb11bde87785f229ecd366c2d4e44432832580e0608c579e4cb76f383f7f551eac7471b00c36982"
]
EXPECTED = [
"00000000002bef4107f882f6115e0b01f348d21195dacd3582aa2dabd7985806",
"00000000003a0d11bdd5eb634e08b7feddcfbbf228ed35d250daf19f1c88fc94",
"00000000000b40f895f288e13244728a6c2d9d59d8aff29c65f8dd5114a8ca81",
"00000000003007005891cd4923031e99d8e8d72f6e8e7edc6a86181897e105fe",
"000000000018f0b426a4afc7130ccb47fa02af730d345b4fe7c7724d3800ec8c"
]
def check_scrypt(input, expected):
output = ltc_scrypt.getPoWHash(input)
assert expected == output, f"expected {expected}, got {output}"
def run_test():
if len(INPUT) != len(EXPECTED):
raise Exception("INPUT and EXPECTED arrays have different lengths, aborting.")
for i in range(len(INPUT)):
check_scrypt(bytes.fromhex(INPUT[i]), bytes.fromhex(EXPECTED[i])[::-1])
print("test successful.")
if __name__ == '__main__':
run_test()