Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
cf45bc81
Unverified
Commit
cf45bc81
authored
Mar 14, 2022
by
Conner Fromknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add db.LoadTeleport* tests
parent
cbf1ff41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
0 deletions
+75
-0
db_test.go
go/teleportr/db/db_test.go
+75
-0
No files found.
go/teleportr/db/db_test.go
View file @
cf45bc81
...
...
@@ -495,3 +495,78 @@ func TestDeletePendingTx(t *testing.T) {
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
pendingTxs
)
}
// TestLoadTeleports asserts that LoadTeleportByDepositHash and
// LoadTeleportsByAddress are able to query for a spcific deposit in various
// stages through the teleport process.
func
TestLoadTeleports
(
t
*
testing
.
T
)
{
t
.
Parallel
()
d
:=
newDatabase
(
t
)
defer
d
.
Close
()
address
:=
common
.
HexToAddress
(
"0x01"
)
amount
:=
big
.
NewInt
(
1000
)
depTxnHash
:=
common
.
HexToHash
(
"0x0d01"
)
depBlockNumber
:=
uint64
(
1
)
disTxnHash
:=
common
.
HexToHash
(
"0x0e01"
)
disBlockNumber
:=
uint64
(
2
)
// Insert deposit.
deposit1
:=
db
.
Deposit
{
ID
:
1
,
Address
:
address
,
Amount
:
amount
,
ConfirmationInfo
:
db
.
ConfirmationInfo
{
TxnHash
:
depTxnHash
,
BlockNumber
:
depBlockNumber
,
BlockTimestamp
:
testTimestamp
,
},
}
err
:=
d
.
UpsertDeposits
([]
db
.
Deposit
{
deposit1
},
0
)
require
.
Nil
(
t
,
err
)
// The same, undisbursed teleport should be retruned by hash and address.
expTeleport
:=
db
.
Teleport
{
Deposit
:
deposit1
,
Disbursement
:
nil
,
}
teleport
,
err
:=
d
.
LoadTeleportByDepositHash
(
depTxnHash
)
require
.
Nil
(
t
,
err
)
require
.
NotNil
(
t
,
teleport
)
require
.
Equal
(
t
,
expTeleport
,
*
teleport
)
teleports
,
err
:=
d
.
LoadTeleportsByAddress
(
address
)
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
[]
db
.
Teleport
{
expTeleport
},
teleports
)
// Insert a disbursement for the above deposit.
err
=
d
.
UpsertDisbursement
(
1
,
disTxnHash
,
disBlockNumber
,
testTimestamp
,
true
,
)
require
.
Nil
(
t
,
err
)
// The now-complete teleport should be returned from both queries.
expTeleport
=
db
.
Teleport
{
Deposit
:
deposit1
,
Disbursement
:
&
db
.
Disbursement
{
Success
:
true
,
ConfirmationInfo
:
db
.
ConfirmationInfo
{
TxnHash
:
disTxnHash
,
BlockNumber
:
disBlockNumber
,
BlockTimestamp
:
testTimestamp
,
},
},
}
teleport
,
err
=
d
.
LoadTeleportByDepositHash
(
depTxnHash
)
require
.
Nil
(
t
,
err
)
require
.
NotNil
(
t
,
teleport
)
require
.
Equal
(
t
,
expTeleport
,
*
teleport
)
teleports
,
err
=
d
.
LoadTeleportsByAddress
(
address
)
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
[]
db
.
Teleport
{
expTeleport
},
teleports
)
}
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