mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 10:28:10 +01:00
Fix wallet headings, loading existing smsges and amount compare precision.
This commit is contained in:
@@ -9,6 +9,8 @@ import unittest
|
||||
from basicswap.util import (
|
||||
SerialiseNum,
|
||||
DeserialiseNum,
|
||||
makeInt,
|
||||
format8,
|
||||
)
|
||||
from basicswap.basicswap import (
|
||||
Coins,
|
||||
@@ -19,15 +21,13 @@ from basicswap.basicswap import (
|
||||
)
|
||||
|
||||
|
||||
def test_case(v, nb=None):
|
||||
b = SerialiseNum(v)
|
||||
if nb is not None:
|
||||
assert(len(b) == nb)
|
||||
assert(v == DeserialiseNum(b))
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
def test_serialise_num(self):
|
||||
def test_case(v, nb=None):
|
||||
b = SerialiseNum(v)
|
||||
if nb is not None:
|
||||
assert(len(b) == nb)
|
||||
assert(v == DeserialiseNum(b))
|
||||
test_case(0, 1)
|
||||
test_case(1, 1)
|
||||
test_case(16, 1)
|
||||
@@ -57,6 +57,26 @@ class Test(unittest.TestCase):
|
||||
decoded = decodeSequence(encoded)
|
||||
assert(decoded == blocks_val)
|
||||
|
||||
def test_makeInt(self):
|
||||
def test_case(v):
|
||||
sv = format8(makeInt(v))
|
||||
# Strip
|
||||
for i in range(7):
|
||||
if sv[-1] == '0':
|
||||
sv = sv[:-1]
|
||||
assert(sv == v)
|
||||
test_case('0.00899999')
|
||||
test_case('899999.0')
|
||||
test_case('899999.00899999')
|
||||
test_case('1.0')
|
||||
test_case('1.1')
|
||||
test_case('1.2')
|
||||
test_case('0.00899991')
|
||||
test_case('0.0089999')
|
||||
test_case('0.0089991')
|
||||
test_case('0.123')
|
||||
test_case('123000.000123')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user