Skip to content
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

Make factories for test data in ./service package #31

Open
placer14 opened this issue Nov 15, 2018 · 0 comments
Open

Make factories for test data in ./service package #31

placer14 opened this issue Nov 15, 2018 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@placer14
Copy link
Member

Found intermittent failures in the multiwallet/service package. Possibly due to shared test data amongst the tests. Since comparisons in the failures found below are both related to the MockTransactions which are used throughout those tests, we should fix the unit tests to use their own fresh test data for each time. This way, if there are failures, we can be sure that it's not due to one test cobbering our expected state from underneath another test.

Example failures encountered:

$ go test ./...
2018/11/15 17:44:11 cached block height missing: using default
2018/11/15 17:44:11 Querying for Bitcoin chain height
2018/11/15 17:44:11 Bitcoin chain height: 1289594
2018/11/15 17:44:11 Querying for Bitcoin utxos
2018/11/15 17:44:11 Querying for Bitcoin transactions
2018/11/15 17:44:11 Downloaded 4 Bitcoin transactions
2018/11/15 17:44:11 Downloaded 3 Bitcoin utxos
2018/11/15 17:44:11 cached block height missing: using default
2018/11/15 17:44:11 Querying for Bitcoin transactions
2018/11/15 17:44:11 Downloaded 4 Bitcoin transactions
2018/11/15 17:44:11 cached block height missing: using default
2018/11/15 17:44:11 Querying for Bitcoin utxos
2018/11/15 17:44:11 Downloaded 3 Bitcoin utxos
2018/11/15 17:44:11 cached block height missing: using default
2018/11/15 17:44:11 Querying for Bitcoin transactions
2018/11/15 17:44:11 Downloaded 4 Bitcoin transactions
2018/11/15 17:44:11 cached block height missing: using default
2018/11/15 17:44:11 New incoming Bitcoin transaction: 54ebaa07c42216393b9d5816e40dd608593b92c42e2d6525f45bdd36bce8fe4d
2018/11/15 17:44:11 New incoming Bitcoin transaction: ff2b865c3b73439912eebf4cce9a15b12c7d7bcdd14ae1110a90541426c4e7c5
2018/11/15 17:44:11 cached block height missing: using default
2018/11/15 17:44:11 Received new Bitcoin block at height 1289595: 0000000000000142ffae87224cb67206e93bf934f9fdeba75d02a7050acc6136
2018/11/15 17:44:11 New incoming Bitcoin transaction: 54ebaa07c42216393b9d5816e40dd608593b92c42e2d6525f45bdd36bce8fe4d
2018/11/15 17:44:11 Received new Bitcoin block at height 1289596: 000000000000033ef24180d5d282d0e6d03b1185e29421fda97e1ba0ffd7c918
2018/11/15 17:44:12 Received new Bitcoin block at height 1289595: 0000000000000000003c4b7f56e45567980f02012ea00d8e384267a2d825fcf9
2018/11/15 17:44:12 Reorg in the Bitcoin chain! Re-scanning wallet
2018/11/15 17:44:12 Querying for Bitcoin chain height
2018/11/15 17:44:12 Bitcoin chain height: 1289594
2018/11/15 17:44:12 Querying for Bitcoin transactions
2018/11/15 17:44:12 Querying for Bitcoin utxos
2018/11/15 17:44:12 Downloaded 4 Bitcoin transactions
2018/11/15 17:44:12 Downloaded 3 Bitcoin utxos
2018/11/15 17:44:12 cached block height missing: using default
--- FAIL: TestWalletService_listenersFired (0.01s)
        wallet_service_test.go:367: Failed to fire transaction callback
        wallet_service_test.go:374: Returned incorrect txid
        wallet_service_test.go:377: Returned incorrect value
        wallet_service_test.go:395: Failed to fire transaction callback
        wallet_service_test.go:419: Failed to fire transaction callback
        wallet_service_test.go:426: Returned incorrect txid
        wallet_service_test.go:429: Returned incorrect value
        wallet_service_test.go:432: Returned incorrect height
        wallet_service_test.go:435: Returned incorrect watch only
2018/11/15 17:44:12 cached block height missing: using default
FAIL
FAIL    github.com/OpenBazaar/multiwallet/service       1.133s

Another:

$ go clean -testcache && go test ./service
2018/11/15 17:56:53 cached block height missing: using default
2018/11/15 17:56:53 Querying for Bitcoin chain height
2018/11/15 17:56:53 Bitcoin chain height: 1289594
2018/11/15 17:56:53 Querying for Bitcoin utxos
2018/11/15 17:56:53 Querying for Bitcoin transactions
2018/11/15 17:56:53 Downloaded 4 Bitcoin transactions
2018/11/15 17:56:53 Downloaded 3 Bitcoin utxos
2018/11/15 17:56:53 cached block height missing: using default
2018/11/15 17:56:53 Querying for Bitcoin transactions
2018/11/15 17:56:53 Downloaded 4 Bitcoin transactions
2018/11/15 17:56:53 cached block height missing: using default
2018/11/15 17:56:53 Querying for Bitcoin utxos
2018/11/15 17:56:53 Downloaded 3 Bitcoin utxos
2018/11/15 17:56:53 cached block height missing: using default
2018/11/15 17:56:53 Querying for Bitcoin transactions
2018/11/15 17:56:53 Downloaded 4 Bitcoin transactions
2018/11/15 17:56:53 cached block height missing: using default
2018/11/15 17:56:53 New incoming Bitcoin transaction: 54ebaa07c42216393b9d5816e40dd608593b92c42e2d6525f45bdd36bce8fe4d
--- FAIL: TestWalletService_ProcessIncomingTransaction (0.01s)
        wallet_service_test.go:211: Failed to update state correctly
panic: runtime error: index out of range [recovered]
        panic: runtime error: index out of range

goroutine 12 [running]:
testing.tRunner.func1(0xc42012a870)
        /usr/local/Cellar/go/1.10.3/libexec/src/testing/testing.go:742 +0x29d
panic(0x139aa00, 0x1746370)
        /usr/local/Cellar/go/1.10.3/libexec/src/runtime/panic.go:502 +0x229
github.com/OpenBazaar/multiwallet/service.TestWalletService_ProcessIncomingTransaction(0xc42012a870)
        /Users/mg/go/src/github.com/OpenBazaar/multiwallet/service/wallet_service_test.go:213 +0xb4a
testing.tRunner(0xc42012a870, 0x1542898)
        /usr/local/Cellar/go/1.10.3/libexec/src/testing/testing.go:777 +0xd0
created by testing.(*T).Run
        /usr/local/Cellar/go/1.10.3/libexec/src/testing/testing.go:824 +0x2e0
FAIL    github.com/OpenBazaar/multiwallet/service       0.068s
@placer14 placer14 added bug Something isn't working help wanted Extra attention is needed labels Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant