-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simnet trading tests #432
Conversation
Sample test logs from running the trade tests using Test logs
|
b966792
to
2a46359
Compare
ea78da8
to
232b487
Compare
I was hoping to add test for the recently merged refund recovery scenarios but that will have to wait for #438 as 1 key factor determining refundability is the swap locktimes. If that goes in first, I'll update this PR with the refund recovery test cases. Otherwise, that will come in a subsequent PR. |
PR #438 is in if you want to update for the refund/find-redeem recovery scenarios. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of my test attempts ended at trying to pay the fee. over 90%
failure log
[joe@hyrule dcrdex]$ go test -v -tags harness ./client/core
=== RUN TestTrading
2020-06-10 16:58:44.336 [INF] TEST: === SETUP
2020-06-10 16:58:44.336 [INF] TEST: [client 1] core created
2020-06-10 16:58:45.368 [INF] TEST: [client 1] core initialized
2020-06-10 16:58:45.409 [INF] TEST: [client 1] connected dcr wallet
2020-06-10 16:58:45.555 [INF] TEST: [client 1] connected btc wallet
2020-06-10 16:58:45.785 [ERR] CORE: Error getting confirmations for 334eb3e2aaa5dc7c7db51e329c5aa02537d3186813f88edbf5b81bba37f1110100000000: -5: no information for transaction
2020-06-10 16:58:45.785 [INF] TEST: [client 1] connected DEX 127.0.0.1:17273
2020-06-10 16:58:45.792 [INF] TEST: [client 1] mined 1 blocks on dcr trading1 for fee payment confirmation
2020-06-10 16:58:45.792 [INF] TEST: [client 1] waiting 5 seconds for fee confirmation notice
TestTrading: trade_simnet_test.go:223: error starting clients: fee payment not confirmed after 5 seconds
--- FAIL: TestTrading (6.47s)
FAIL
FAIL decred.org/dcrdex/client/core 6.511s
FAIL
[joe@hyrule dcrdex]$ go test -v -tags harness ./client/core
=== RUN TestTrading
2020-06-10 16:59:07.141 [INF] TEST: === SETUP
2020-06-10 16:59:07.141 [INF] TEST: [client 1] core created
2020-06-10 16:59:08.175 [INF] TEST: [client 1] core initialized
2020-06-10 16:59:08.216 [INF] TEST: [client 1] connected dcr wallet
2020-06-10 16:59:08.339 [INF] TEST: [client 1] connected btc wallet
2020-06-10 16:59:08.502 [INF] TEST: [client 1] connected DEX 127.0.0.1:17273
2020-06-10 16:59:08.509 [INF] TEST: [client 1] mined 1 blocks on dcr trading1 for fee payment confirmation
2020-06-10 16:59:08.509 [INF] TEST: [client 1] waiting 5 seconds for fee confirmation notice
2020-06-10 16:59:09.219 [INF] TEST: [client 1] fee payment confirmed
2020-06-10 16:59:09.219 [INF] TEST: [client 2] core created
2020-06-10 16:59:10.254 [INF] TEST: [client 2] core initialized
2020-06-10 16:59:10.285 [INF] TEST: [client 2] connected dcr wallet
2020-06-10 16:59:10.435 [INF] TEST: [client 2] connected btc wallet
2020-06-10 16:59:10.582 [ERR] CORE: Error getting confirmations for e0b87e7949ffd158c74f0bcdc920a572fe0fe659aa82249051922eaa77bfbb0700000000: -5: no information for transaction
2020-06-10 16:59:10.582 [INF] TEST: [client 2] connected DEX 127.0.0.1:17273
2020-06-10 16:59:10.590 [INF] TEST: [client 2] mined 1 blocks on dcr trading2 for fee payment confirmation
2020-06-10 16:59:10.590 [INF] TEST: [client 2] waiting 5 seconds for fee confirmation notice
TestTrading: trade_simnet_test.go:223: error starting clients: fee payment not confirmed after 5 seconds
--- FAIL: TestTrading (8.46s)
FAIL
FAIL decred.org/dcrdex/client/core 8.532s
FAIL
The --race flag seems to give it the time it need to get the fee paid for some reason. But there are a lot of races shown.
races
=== RUN TestTrading
2020-06-10 17:29:17.300 [INF] TEST: === SETUP
2020-06-10 17:29:17.301 [INF] TEST: [client 1] core created
2020-06-10 17:29:18.404 [INF] TEST: [client 1] core initialized
2020-06-10 17:29:18.488 [INF] TEST: [client 1] connected dcr wallet
2020-06-10 17:29:18.676 [INF] TEST: [client 1] connected btc wallet
2020-06-10 17:29:19.386 [INF] TEST: [client 1] connected DEX 127.0.0.1:17273
2020-06-10 17:29:19.389 [INF] TEST: [client 1] mined 1 blocks on dcr trading1 for fee payment confirmation
2020-06-10 17:29:19.389 [INF] TEST: [client 1] waiting 5 seconds for fee confirmation notice
2020-06-10 17:29:19.504 [INF] TEST: [client 1] fee payment confirmed
2020-06-10 17:29:19.505 [INF] TEST: [client 2] core created
2020-06-10 17:29:20.607 [INF] TEST: [client 2] core initialized
2020-06-10 17:29:20.723 [INF] TEST: [client 2] connected dcr wallet
2020-06-10 17:29:20.915 [INF] TEST: [client 2] connected btc wallet
2020-06-10 17:29:21.274 [INF] TEST: [client 2] connected DEX 127.0.0.1:17273
2020-06-10 17:29:21.281 [INF] TEST: [client 2] mined 1 blocks on dcr trading2 for fee payment confirmation
2020-06-10 17:29:21.281 [INF] TEST: [client 2] waiting 5 seconds for fee confirmation notice
2020-06-10 17:29:21.752 [INF] TEST: [client 2] fee payment confirmed
2020-06-10 17:29:21.752 [INF] TEST: === SETUP COMPLETED
=== RUN TestTrading/success
2020-06-10 17:29:21.753 [INF] TEST: [client 1] unlocking wallets
2020-06-10 17:29:22.264 [INF] TEST: [client 1] updating balances
2020-06-10 17:29:22.385 [INF] TEST: [client 2] unlocking wallets
2020-06-10 17:29:22.897 [INF] TEST: [client 2] updating balances
2020-06-10 17:29:23.032 [INF] TEST: [client 1] placed order selling 12.00000000 dcr at 0.00015000 btc/dcr (ab34b75a)
2020-06-10 17:29:23.145 [INF] TEST: [client 2] placed order buying 12.00000000 dcr at 0.00015000 btc/dcr (cd2ca6e4)
2020-06-10 17:29:23.145 [INF] TEST: [client 1] waiting for matches on order ab34b75a
2020-06-10 17:29:23.145 [INF] TEST: [client 2] waiting for matches on order cd2ca6e4
2020-06-10 17:29:24.025 [INF] TEST: [client 1] 1 match(es) received for order ab34b75a
2020-06-10 17:29:24.026 [INF] TEST: [client 1] Taker on match 1ed97794, amount 12.00000000 dcr
2020-06-10 17:29:24.049 [INF] TEST: [client 2] 1 match(es) received for order cd2ca6e4
2020-06-10 17:29:24.049 [INF] TEST: [client 2] Maker on match 1ed97794, amount 12.00000000 dcr
==================
WARNING: DATA RACE
Write at 0x00c000ec4060 by goroutine 62:
decred.org/dcrdex/client/core.(*matchTracker).setStatus()
/home/joe/git/dcrdex/client/core/trade.go:49 +0x2c91
decred.org/dcrdex/client/core.(*trackedTrade).swapMatches()
/home/joe/git/dcrdex/client/core/trade.go:718 +0x2c5d
decred.org/dcrdex/client/core.(*trackedTrade).tick()
/home/joe/git/dcrdex/client/core/trade.go:562 +0x18fe
decred.org/dcrdex/client/core.(*trackedTrade).negotiate()
/home/joe/git/dcrdex/client/core/trade.go:377 +0x15f5
decred.org/dcrdex/client/core.(*dexConnection).runMatches()
/home/joe/git/dcrdex/client/core/core.go:300 +0x1f2
decred.org/dcrdex/client/core.handleMatchRoute()
/home/joe/git/dcrdex/client/core/core.go:2591 +0x391
decred.org/dcrdex/client/core.(*Core).listen()
/home/joe/git/dcrdex/client/core/core.go:2505 +0x4d0
Previous read at 0x00c000ec4060 by goroutine 97:
decred.org/dcrdex/client/core.monitorTradeForTestOrder.func3()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:451 +0x1b1
decred.org/dcrdex/client/core.tryUntil()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:531 +0x1e3
decred.org/dcrdex/client/core.monitorTradeForTestOrder()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:448 +0x1549
decred.org/dcrdex/client/core.simpleTradeTest.func2()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:332 +0xb8
golang.org/x/sync/errgroup.(*Group).Go.func1()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:57 +0x85
Goroutine 62 (running) created at:
decred.org/dcrdex/client/core.(*Core).connectDEX()
/home/joe/git/dcrdex/client/core/core.go:2335 +0x1cb8
decred.org/dcrdex/client/core.(*Core).Register()
/home/joe/git/dcrdex/client/core/core.go:1010 +0x3b5
decred.org/dcrdex/client/core.startClients()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:153 +0xfd8
decred.org/dcrdex/client/core.TestTrading()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:221 +0x436
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
Goroutine 97 (running) created at:
golang.org/x/sync/errgroup.(*Group).Go()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:54 +0x73
decred.org/dcrdex/client/core.simpleTradeTest()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:331 +0x937
decred.org/dcrdex/client/core.testTradeSuccess()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:248 +0xb6
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
==================
==================
WARNING: DATA RACE
Read at 0x00c000ec4060 by goroutine 97:
decred.org/dcrdex/client/core.monitorTradeForTestOrder.func3()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:451 +0x1b1
decred.org/dcrdex/client/core.tryUntil()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:531 +0x1e3
decred.org/dcrdex/client/core.monitorTradeForTestOrder()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:448 +0x1549
decred.org/dcrdex/client/core.simpleTradeTest.func2()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:332 +0xb8
golang.org/x/sync/errgroup.(*Group).Go.func1()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:57 +0x85
Previous write at 0x00c000ec4060 by goroutine 62:
decred.org/dcrdex/client/core.(*matchTracker).setStatus()
/home/joe/git/dcrdex/client/core/trade.go:49 +0x2c91
decred.org/dcrdex/client/core.(*trackedTrade).swapMatches()
/home/joe/git/dcrdex/client/core/trade.go:718 +0x2c5d
decred.org/dcrdex/client/core.(*trackedTrade).tick()
/home/joe/git/dcrdex/client/core/trade.go:562 +0x18fe
decred.org/dcrdex/client/core.(*trackedTrade).negotiate()
/home/joe/git/dcrdex/client/core/trade.go:377 +0x15f5
decred.org/dcrdex/client/core.(*dexConnection).runMatches()
/home/joe/git/dcrdex/client/core/core.go:300 +0x1f2
decred.org/dcrdex/client/core.handleMatchRoute()
/home/joe/git/dcrdex/client/core/core.go:2591 +0x391
decred.org/dcrdex/client/core.(*Core).listen()
/home/joe/git/dcrdex/client/core/core.go:2505 +0x4d0
Goroutine 97 (running) created at:
golang.org/x/sync/errgroup.(*Group).Go()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:54 +0x73
decred.org/dcrdex/client/core.simpleTradeTest()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:331 +0x937
decred.org/dcrdex/client/core.testTradeSuccess()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:248 +0xb6
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
Goroutine 62 (running) created at:
decred.org/dcrdex/client/core.(*Core).connectDEX()
/home/joe/git/dcrdex/client/core/core.go:2335 +0x1cb8
decred.org/dcrdex/client/core.(*Core).Register()
/home/joe/git/dcrdex/client/core/core.go:1010 +0x3b5
decred.org/dcrdex/client/core.startClients()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:153 +0xfd8
decred.org/dcrdex/client/core.TestTrading()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:221 +0x436
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
==================
2020-06-10 17:29:24.099 [INF] TEST: [client 2] NOW =====> MakerSwapCast
2020-06-10 17:29:25.108 [INF] TEST: [client 2] Mined 1 blocks for Maker's swap, match 1ed97794
2020-06-10 17:29:25.108 [INF] TEST: [client 2] updated btc balance diff with -0.001800
==================
WARNING: DATA RACE
Write at 0x00c004736140 by goroutine 76:
decred.org/dcrdex/client/core.(*matchTracker).setStatus()
/home/joe/git/dcrdex/client/core/trade.go:49 +0x24e2
decred.org/dcrdex/client/core.(*trackedTrade).processAudit()
/home/joe/git/dcrdex/client/core/trade.go:966 +0x24ae
decred.org/dcrdex/client/core.handleAuditRoute()
/home/joe/git/dcrdex/client/core/core.go:2608 +0x2ae
decred.org/dcrdex/client/core.(*Core).listen()
/home/joe/git/dcrdex/client/core/core.go:2505 +0x4d0
Previous read at 0x00c004736140 by goroutine 93:
decred.org/dcrdex/client/core.monitorTradeForTestOrder.func3()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:451 +0x1b1
decred.org/dcrdex/client/core.tryUntil()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:531 +0x1e3
decred.org/dcrdex/client/core.monitorTradeForTestOrder()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:448 +0x1549
decred.org/dcrdex/client/core.simpleTradeTest.func1()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:329 +0xb8
golang.org/x/sync/errgroup.(*Group).Go.func1()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:57 +0x85
Goroutine 76 (running) created at:
decred.org/dcrdex/client/core.(*Core).connectDEX()
/home/joe/git/dcrdex/client/core/core.go:2335 +0x1cb8
decred.org/dcrdex/client/core.(*Core).Register()
/home/joe/git/dcrdex/client/core/core.go:1010 +0x3b5
decred.org/dcrdex/client/core.startClients()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:153 +0xfd8
decred.org/dcrdex/client/core.TestTrading()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:221 +0x436
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
Goroutine 93 (running) created at:
golang.org/x/sync/errgroup.(*Group).Go()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:54 +0x73
decred.org/dcrdex/client/core.simpleTradeTest()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:328 +0x853
decred.org/dcrdex/client/core.testTradeSuccess()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:248 +0xb6
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
==================
==================
WARNING: DATA RACE
Read at 0x00c004736140 by goroutine 93:
decred.org/dcrdex/client/core.monitorTradeForTestOrder.func3()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:451 +0x1b1
decred.org/dcrdex/client/core.tryUntil()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:531 +0x1e3
decred.org/dcrdex/client/core.monitorTradeForTestOrder()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:448 +0x1549
decred.org/dcrdex/client/core.simpleTradeTest.func1()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:329 +0xb8
golang.org/x/sync/errgroup.(*Group).Go.func1()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:57 +0x85
Previous write at 0x00c004736140 by goroutine 76:
decred.org/dcrdex/client/core.(*matchTracker).setStatus()
/home/joe/git/dcrdex/client/core/trade.go:49 +0x24e2
decred.org/dcrdex/client/core.(*trackedTrade).processAudit()
/home/joe/git/dcrdex/client/core/trade.go:966 +0x24ae
decred.org/dcrdex/client/core.handleAuditRoute()
/home/joe/git/dcrdex/client/core/core.go:2608 +0x2ae
decred.org/dcrdex/client/core.(*Core).listen()
/home/joe/git/dcrdex/client/core/core.go:2505 +0x4d0
Goroutine 93 (running) created at:
golang.org/x/sync/errgroup.(*Group).Go()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:54 +0x73
decred.org/dcrdex/client/core.simpleTradeTest()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:328 +0x853
decred.org/dcrdex/client/core.testTradeSuccess()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:248 +0xb6
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
Goroutine 76 (running) created at:
decred.org/dcrdex/client/core.(*Core).connectDEX()
/home/joe/git/dcrdex/client/core/core.go:2335 +0x1cb8
decred.org/dcrdex/client/core.(*Core).Register()
/home/joe/git/dcrdex/client/core/core.go:1010 +0x3b5
decred.org/dcrdex/client/core.startClients()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:153 +0xfd8
decred.org/dcrdex/client/core.TestTrading()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:221 +0x436
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
==================
2020-06-10 17:29:27.304 [INF] TEST: [client 1] NOW =====> MakerSwapCast
2020-06-10 17:29:27.325 [INF] TEST: [client 2] NOW =====> TakerSwapCast
2020-06-10 17:29:27.347 [INF] TEST: [client 1] NOW =====> TakerSwapCast
2020-06-10 17:29:28.355 [INF] TEST: [client 1] Mined 1 blocks for Taker's swap, match 1ed97794
2020-06-10 17:29:28.355 [INF] TEST: [client 1] updated dcr balance diff with -12.000000
2020-06-10 17:29:28.743 [INF] TEST: [client 1] NOW =====> MakerRedeemed
2020-06-10 17:29:28.745 [INF] TEST: [client 2] NOW =====> MakerRedeemed
2020-06-10 17:29:29.753 [INF] TEST: [client 2] Mined 1 blocks for Maker's redeem, match 1ed97794
2020-06-10 17:29:29.753 [INF] TEST: [client 2] updated dcr balance diff with +12.000000
2020-06-10 17:29:36.864 [INF] TEST: [client 2] NOW =====> MatchComplete
2020-06-10 17:29:36.864 [INF] TEST: [client 1] NOW =====> MatchComplete
==================
WARNING: DATA RACE
Read at 0x00c000bec2b0 by goroutine 90:
decred.org/dcrdex/client/core.(*trackedTrade).isSwappable()
/home/joe/git/dcrdex/client/core/trade.go:406 +0x56
decred.org/dcrdex/client/core.(*trackedTrade).tick()
/home/joe/git/dcrdex/client/core/trade.go:536 +0x451
decred.org/dcrdex/client/core.(*dexConnection).tickAsset()
/home/joe/git/dcrdex/client/core/core.go:340 +0x1ea
decred.org/dcrdex/client/core.(*Core).tipChange()
/home/joe/git/dcrdex/client/core/core.go:2683 +0x41b
decred.org/dcrdex/client/core.(*Core).loadWallet.func1()
/home/joe/git/dcrdex/client/core/core.go:854 +0x7e
decred.org/dcrdex/client/asset/dcr.(*ExchangeWallet).monitorBlocks()
/home/joe/git/dcrdex/client/asset/dcr/dcr.go:1607 +0x44b
decred.org/dcrdex/client/asset/dcr.(*ExchangeWallet).Connect.func1()
/home/joe/git/dcrdex/client/asset/dcr/dcr.go:356 +0x89
Previous write at 0x00c000bec2b0 by goroutine 93:
decred.org/dcrdex/client/core.monitorTradeForTestOrder.func3()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:454 +0x10a1
decred.org/dcrdex/client/core.tryUntil()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:531 +0x1e3
decred.org/dcrdex/client/core.monitorTradeForTestOrder()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:448 +0x1549
decred.org/dcrdex/client/core.simpleTradeTest.func1()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:329 +0xb8
golang.org/x/sync/errgroup.(*Group).Go.func1()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:57 +0x85
Goroutine 90 (running) created at:
decred.org/dcrdex/client/asset/dcr.(*ExchangeWallet).Connect()
/home/joe/git/dcrdex/client/asset/dcr/dcr.go:354 +0x406
decred.org/dcrdex/dex.(*ConnectionMaster).Connect()
/home/joe/git/dcrdex/dex/runner.go:100 +0xc1
decred.org/dcrdex/client/core.(*xcWallet).Connect()
/home/joe/git/dcrdex/client/core/wallet.go:100 +0x68
decred.org/dcrdex/client/core.(*Core).CreateWallet()
/home/joe/git/dcrdex/client/core/core.go:790 +0x946
decred.org/dcrdex/client/core.startClients()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:125 +0x860
decred.org/dcrdex/client/core.TestTrading()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:221 +0x436
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
Goroutine 93 (running) created at:
golang.org/x/sync/errgroup.(*Group).Go()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:54 +0x73
decred.org/dcrdex/client/core.simpleTradeTest()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:328 +0x853
decred.org/dcrdex/client/core.testTradeSuccess()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:248 +0xb6
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
==================
==================
WARNING: DATA RACE
Read at 0x00c0057105b0 by goroutine 62:
decred.org/dcrdex/client/core.(*trackedTrade).isSwappable()
/home/joe/git/dcrdex/client/core/trade.go:406 +0x56
decred.org/dcrdex/client/core.(*trackedTrade).tick()
/home/joe/git/dcrdex/client/core/trade.go:536 +0x451
decred.org/dcrdex/client/core.handleRedemptionRoute()
/home/joe/git/dcrdex/client/core/core.go:2638 +0x2d2
decred.org/dcrdex/client/core.(*Core).listen()
/home/joe/git/dcrdex/client/core/core.go:2505 +0x4d0
Previous write at 0x00c0057105b0 by goroutine 97:
decred.org/dcrdex/client/core.monitorTradeForTestOrder.func3()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:454 +0x10a1
decred.org/dcrdex/client/core.tryUntil()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:531 +0x1e3
decred.org/dcrdex/client/core.monitorTradeForTestOrder()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:448 +0x1549
decred.org/dcrdex/client/core.simpleTradeTest.func2()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:332 +0xb8
golang.org/x/sync/errgroup.(*Group).Go.func1()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:57 +0x85
Goroutine 62 (running) created at:
decred.org/dcrdex/client/core.(*Core).connectDEX()
/home/joe/git/dcrdex/client/core/core.go:2335 +0x1cb8
decred.org/dcrdex/client/core.(*Core).Register()
/home/joe/git/dcrdex/client/core/core.go:1010 +0x3b5
decred.org/dcrdex/client/core.startClients()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:153 +0xfd8
decred.org/dcrdex/client/core.TestTrading()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:221 +0x436
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
Goroutine 97 (finished) created at:
golang.org/x/sync/errgroup.(*Group).Go()
/home/joe/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:54 +0x73
decred.org/dcrdex/client/core.simpleTradeTest()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:331 +0x937
decred.org/dcrdex/client/core.testTradeSuccess()
/home/joe/git/dcrdex/client/core/trade_simnet_test.go:248 +0xb6
testing.tRunner()
/home/joe/.local/go/src/testing/testing.go:991 +0x1eb
==================
2020-06-10 17:29:37.872 [INF] TEST: [client 1] Mined 1 blocks for Taker's redeem, match 1ed97794
2020-06-10 17:29:37.872 [INF] TEST: [client 1] updated btc balance diff with +0.001800
2020-06-10 17:29:37.872 [INF] TEST: Trades ended at MatchComplete.
2020-06-10 17:29:38.872 [INF] TEST: [client 1] updating balances
2020-06-10 17:29:38.890 [INF] TEST: [client 1] dcr balance change -12.00002500 is in expected range of -13.00000000 - -12.00000000
2020-06-10 17:29:38.890 [INF] TEST: [client 1] btc balance change 0.00147800 is in expected range of -0.99820000 - 0.00180000
2020-06-10 17:29:38.890 [INF] TEST: [client 2] updating balances
2020-06-10 17:29:38.904 [INF] TEST: [client 2] dcr balance change 11.99996510 is in expected range of 11.00000000 - 12.00000000
2020-06-10 17:29:38.904 [INF] TEST: [client 2] btc balance change -0.00202300 is in expected range of -1.00180000 - -0.00180000
TestTrading/success: testing.go:906: race detected during execution of test
TestTrading: testing.go:906: race detected during execution of test
--- FAIL: TestTrading (21.60s)
--- FAIL: TestTrading/success (17.15s)
2020-06-10 17:29:38.905 [ERR] CORE: refreshUser: error checking if app is initialized: database not open
2020-06-10 17:29:38.906 [ERR] CORE: refreshUser: error checking if app is initialized: database not open
: testing.go:906: race detected during execution of test
FAIL
FAIL decred.org/dcrdex/client/core 22.623s
FAIL
Could it be related to #392? In any case, a timeout error should show on the test logs, so maybe not. I'll increase the wait period for the fee payment confirmation notice and see if that improves things for you. I guess it may take more than 5 seconds after mining the fee tx for the payment to get confirmed by the client and validated by the server. Talking about real fee payment errors showing up on the test log, your failure log has an example:
Weird. The success may have nothing to do with using the |
Resolved in dbdc497 |
I wanted to get on the refund scenario test but realized that setting shorter locktime values for test purposes would require more than just changing The only solution I see here would be changing the values before building dcrdex and running the tests or moving those values to dex cfg variables. I'll like to get @buck54321's thoughts on this before proceeding. Related discussion here: #438 (comment). |
I am extremely hesitant to make the locktimes variables. If the purpose is for testing, we would presumably want to allow these to be very low values. But if the operator sets the locktimes too low during normal operation, it could result in a nonsensical scenario where the lock times expire before I could maybe get behind this if we only allow them to be variable on simnet. Something like core.lockTimeTaker = dex.LockTimeTaker
if cfg.Network == dex.Simnet && cfg.SimLockTimeTaker != 0 {
core.lockTimeTaker = cfg.SimLockTimeTaker
}
... |
Do you mean But why not set go build -ldflags "-X github.com/decred/dex.LockTimeTaker=something" They would just need to be vars instead of consts. |
Yes. Fixed the original now. |
If I'm reading it right, the |
rpclisten=127.0.0.1:17273 | ||
debuglevel=trace | ||
regfeeconfirms=1 | ||
signingkeypass=keypass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add an admin server pass option too. @JoeGruffins would you want to roll up a PR for that? I can grab it too if you have lots of other stuff on your plate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can put that up as well if no one is on it yet, when applying the next batch of suggestions on this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you like, sure. Should be a straightforward dcrdex config change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - #465
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About this, the adminsrvpass
option isn't really useful without AdminSrvOn
and perhaps AdminSrvAddr
. Should those be included here as well or leave them all out for the tester to append as args to the harness exec cmd e.g.
dcrdex/harness.sh --adminsrvon --adminsrvpass=pass adminsrvaddr=127.0.0.0:PORT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to respond to this, but yes. Also, we should define and export the dexadm
function to work with the harness config. i.e.
dexadm() {
curl --cacert somewhere/rpc.cert --basic -u u:adminpass https://127.0.0.1:16542/api/$1
}
export -f dexadm
Something like that I think.
Right I amended my comment about |
We could do something similar with build tags, like here, but we'd have to edit code to modify the values, which is not great. |
I think that's a pretty good idea, although it makes two new files for these two consts. |
It also doesn't allow us to restrict modifications to simnet. |
The restriction is really just to prevent accidentally using the wrong values/build on mainnet or testnet. An op could easily modify a couple lines of code. But we could still restrict modifications to simnet by having the reference mainnet values in two consts that are not changeable by tags or anything short of editing the code, and the configured ones in the tag-settable code, then compare as you suggested. |
Combining the recommendations/suggestions above re handling separate simnet test locktime values, here's the path I'm considering:
This way, the same binary can be used for any network and the locktime values can be changed at build time (without editing the code) for testnet or simnet. Using the additional string values will be if running on testnet or simnet and the values can be parsed into valid |
Worth hacking it up to see how it looks. The |
Seems legit, @itswisdomagain . Are you going to use some kind of sentinel default for |
Yeah, I'm thinking defaulting both test values to empty strings. |
dbdc497
to
a78aa07
Compare
I believe my problems are being caused because the registration fee is paid and then checked in succession in Register, and the wallet is not ready with transaction data when Line 1095 in ab3dff2
Solves my testing issue and seems like an ok solution. I am surprised that only I am getting the error though. |
No reason not to include them in the harness by default. |
testLockTime struct { | ||
taker time.Duration | ||
maker time.Duration | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made both default and test locktime values unexported, and only exported LockTimeTaker(network)
and LockTimeMaker(network)
functions to force accessors to provide information about the running network.
One other thought was to export DefaultLockTime{M,T}aker
and TestLockTime{M,T}aker
and allow accessors perform network checks before accessing either set of variables but that may make it easy for the wrong set of locktime vars to be used. I think it also prevents avoidable repetition of the if net == Mainnet
code checks from different usage sites.
b2337c3
to
a91fbd2
Compare
This adds a trade_simnet_test that connects to a running dcrdex harness to test different trade sequences. The only trade test implemented in this commit is the test for successful completions of all matches for an order.
This ensures that the trades monitored for each test case executed as expected/desired. In order to ensure balance checks are reliable, non-mining btc and dcr wallets were added to the respective harnesses for use in trading. Mining wallets often get their balances mixed up with mining rewards.
- remove absolute paths computation - dcr-harness: create server_fees account on alpha wallet - dcrdex harness: rebuild dcrdex with test values for maker and taker locktimes - dcrdex harness: drop and re-create the test db - dcrdex harness: change regfeexpub and add shutdown script
- parse test locktime values once, panic on invalid duration values - remove net param from NewSwapper, pass locktimes in swapper cfg
7ff999e
to
27bdd94
Compare
# DEX admin script | ||
cat > "${DCRDEX_DATA_DIR}/dexadm" <<EOF | ||
#!/bin/sh | ||
curl --cacert ${DCRDEX_DATA_DIR}/rpc.cert --basic -u u:adminpass https://127.0.0.1:16542/api/\$@ | ||
EOF | ||
chmod +x "${DCRDEX_DATA_DIR}/dexadm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial idea here was to export a function:
dexadm() {
curl --cacert somewhere/rpc.cert --basic -u u:adminpass https://127.0.0.1:16542/api/$1
}
export -f dexadm
But there are 2 issues with that approach:
- function export is a bash-only feature, I remember reading a convo somewhere where bash scripting was discouraged in dcr projects
- more importantly though, any exported variable or function only takes effect in the current terminal window which is shortly replaced by the tmux window. When I tested it, any exported variable is only available before attaching the tmux window.
The only other thing I think can be done here is to add a tmux ctrl window where a tester can more easily fiddle with the dexadm
script. Ofc, the script can be executed from any other terminal window regardless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I certainly do not discourage bash scripting. I encourage it. I think there are (t)csh fans abound, but that's their preference. bash is by far the most common shell.
Anyway, putting it into "${DCRDEX_DATA_DIR}/dexadm"
is a fine solution.
Resolves #402. Adds
dcrdex
harness that connects to dcr and btc simnet nodes from the dcr, btc harnesses.The following trade tests are implemented:
While a primary motivation for adding the simnet trading tests is to test potential trade disruption states and associated trade/fund recovery implementations, this PR does not exhaust all known possible failure sequences. The plan is to add more tests to the suite in subsequent PRs.
2 dcr and 1 btc wallets are added to the respective simnet harnesses to facilitate trade tests whether using the
trade_simnet_test
or manually. Will follow up with an update to the Simnet Testing wiki with details for using the dcrdex harness to quickly startup a dex server and using the additional wallets for setting up clients for trading.