Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
LaurentMT
samourai-dojo
Commits
296385a8
Verified
Commit
296385a8
authored
Dec 30, 2021
by
Pavel Ševčík
Browse files
Use strictEqual in asserts
parent
7da28b16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
test/lib/bitcoin/addresses-helper-test.js
test/lib/bitcoin/addresses-helper-test.js
+7
-7
test/lib/bitcoin/hd-accounts-helper-test.js
test/lib/bitcoin/hd-accounts-helper-test.js
+9
-9
No files found.
test/lib/bitcoin/addresses-helper-test.js
View file @
296385a8
...
...
@@ -110,7 +110,7 @@ describe('AddressesHelper', () => {
for
(
const
v
of
VECTOR_1
)
{
const
pkb
=
Buffer
.
from
(
v
[
0
],
'
hex
'
)
const
addr
=
addrHelper
.
p2pkhAddress
(
pkb
)
assert
(
addr
===
v
[
1
])
assert
.
strictEqual
(
addr
,
v
[
1
])
}
})
})
...
...
@@ -120,7 +120,7 @@ describe('AddressesHelper', () => {
for
(
const
v
of
VECTOR_1
)
{
const
pkb
=
Buffer
.
from
(
v
[
0
],
'
hex
'
)
const
addr
=
addrHelper
.
p2wpkhP2shAddress
(
pkb
)
assert
(
addr
===
v
[
2
])
assert
.
strictEqual
(
addr
,
v
[
2
])
}
})
})
...
...
@@ -130,7 +130,7 @@ describe('AddressesHelper', () => {
for
(
const
v
of
VECTOR_1
)
{
const
pkb
=
Buffer
.
from
(
v
[
0
],
'
hex
'
)
const
addr
=
addrHelper
.
p2wpkhAddress
(
pkb
)
assert
(
addr
===
v
[
3
])
assert
.
strictEqual
(
addr
,
v
[
3
])
}
})
})
...
...
@@ -138,7 +138,7 @@ describe('AddressesHelper', () => {
describe
(
'
isSupportedPubKey()
'
,
()
=>
{
it
(
'
should successfully detect a compressed pubkey
'
,
()
=>
{
for
(
const
v
of
VECTOR_2
)
{
assert
(
addrHelper
.
isSupportedPubKey
(
v
[
0
])
===
v
[
1
])
assert
.
strictEqual
(
addrHelper
.
isSupportedPubKey
(
v
[
0
])
,
v
[
1
])
}
})
})
...
...
@@ -146,7 +146,7 @@ describe('AddressesHelper', () => {
describe
(
'
isBech32()
'
,
()
=>
{
it
(
'
should successfully detect a bech32 address
'
,
()
=>
{
for
(
const
v
of
VECTOR_3
)
{
assert
(
addrHelper
.
isBech32
(
v
[
0
])
===
v
[
1
])
assert
.
strictEqual
(
addrHelper
.
isBech32
(
v
[
0
])
,
v
[
1
])
}
})
})
...
...
@@ -154,7 +154,7 @@ describe('AddressesHelper', () => {
describe
(
'
getScriptHashFromBech32()
'
,
()
=>
{
it
(
'
should successfully extract the script hash from a bech32 address
'
,
()
=>
{
for
(
const
v
of
VECTOR_4
)
{
assert
(
addrHelper
.
getScriptHashFromBech32
(
v
[
0
])
===
v
[
1
])
assert
.
strictEqual
(
addrHelper
.
getScriptHashFromBech32
(
v
[
0
])
,
v
[
1
])
}
})
})
...
...
@@ -176,7 +176,7 @@ describe('AddressesHelper', () => {
const
sig
=
btcMessage
.
sign
(
msg
,
privKey
,
true
,
prefix
)
// Check that library returns valid result
assert
((
sig
.
compare
(
targetSig
)
===
0
)
===
expectedResult
)
assert
.
strictEqual
((
sig
.
compare
(
targetSig
)
===
0
)
,
expectedResult
)
// Check method
const
result
=
addrHelper
.
verifySignature
(
msg
,
address
,
sig
)
...
...
test/lib/bitcoin/hd-accounts-helper-test.js
View file @
296385a8
...
...
@@ -135,8 +135,8 @@ describe('HdAccountsHelper', () => {
it
(
'
should successfully classify the code stored in db
'
,
()
=>
{
for
(
const
v
of
HD_TYPES_VECTORS
)
{
const
ret
=
hdaHelper
.
classify
(
v
[
0
])
assert
(
ret
.
type
===
v
[
1
])
assert
(
ret
.
locked
===
v
[
2
])
assert
.
strictEqual
(
ret
.
type
,
v
[
1
])
assert
.
strictEqual
(
ret
.
locked
,
v
[
2
])
}
})
})
...
...
@@ -146,7 +146,7 @@ describe('HdAccountsHelper', () => {
it
(
'
should successfully compute the code stored in db
'
,
()
=>
{
for
(
const
v
of
HD_TYPES_VECTORS
)
{
const
ret
=
hdaHelper
.
makeType
(
v
[
1
],
v
[
2
])
assert
(
ret
===
v
[
0
])
assert
.
strictEqual
(
ret
,
v
[
0
])
}
})
})
...
...
@@ -156,21 +156,21 @@ describe('HdAccountsHelper', () => {
it
(
'
should successfully derive addresses with BIP44
'
,
async
()
=>
{
for
(
const
v
of
BIP44_VECTORS
)
{
const
addresses
=
await
hdaHelper
.
deriveAddresses
(
XPUB
,
v
[
0
],
[
v
[
1
]],
hdaHelper
.
BIP44
)
assert
(
addresses
[
0
].
address
===
v
[
2
])
assert
.
strictEqual
(
addresses
[
0
].
address
,
v
[
2
])
}
})
it
(
'
should successfully derive addresses with BIP49
'
,
async
()
=>
{
for
(
const
v
of
BIP49_VECTORS
)
{
const
addresses
=
await
hdaHelper
.
deriveAddresses
(
XPUB
,
v
[
0
],
[
v
[
1
]],
hdaHelper
.
BIP49
)
assert
(
addresses
[
0
].
address
===
v
[
2
])
assert
.
strictEqual
(
addresses
[
0
].
address
,
v
[
2
])
}
})
it
(
'
should successfully derive addresses with BIP84
'
,
async
()
=>
{
for
(
const
v
of
BIP84_VECTORS
)
{
const
addresses
=
await
hdaHelper
.
deriveAddresses
(
XPUB
,
v
[
0
],
[
v
[
1
]],
hdaHelper
.
BIP84
)
assert
(
addresses
[
0
].
address
===
v
[
2
])
assert
.
strictEqual
(
addresses
[
0
].
address
,
v
[
2
])
}
})
...
...
@@ -188,17 +188,17 @@ describe('HdAccountsHelper', () => {
describe
(
'
xlatXPUB()
'
,
()
=>
{
it
(
'
should successfully translate XPUB in YPUB
'
,
()
=>
{
const
xpubXlated
=
hdaHelper
.
xlatXPUB
(
XPUB
)
assert
(
xpubXlated
===
XPUB
)
assert
.
strictEqual
(
xpubXlated
,
XPUB
)
})
it
(
'
should successfully translate YPUB in XPUB
'
,
()
=>
{
const
ypubXlated
=
hdaHelper
.
xlatXPUB
(
YPUB
)
assert
(
ypubXlated
===
XPUB
)
assert
.
strictEqual
(
ypubXlated
,
XPUB
)
})
it
(
'
should successfully translate ZPUB in XPUB
'
,
()
=>
{
const
zpubXlated
=
hdaHelper
.
xlatXPUB
(
ZPUB
)
assert
(
zpubXlated
===
XPUB
)
assert
.
strictEqual
(
zpubXlated
,
XPUB
)
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment