hyperledger-labs / go-perun

🌔 Perun's Blockchain-Agnostic State Channels Framework in Go.
https://perun.network/
Apache License 2.0
55 stars 18 forks source link

Synchronisation problem in alice/bob happy test #323

Open RmbRT opened 2 years ago

RmbRT commented 2 years ago

Location

Alice/Bob happy test

Problem

Sometimes, the test fails when the first update is made, because the receiving side thinks that the channel does not yet exist, even though it's already funded. It's not that easy to debug because the tests are written in independent goroutines and without the use of ConcurrentT.

pkg/test: using rootSeed 1644498878274196796
ERRO[0001] TX failed; error determining reason: CallContract: simulatedBackend cannot access blocks other than the latest block 
--- FAIL: TestHappyAliceBob (5.98s)
    role.go:430: unknown channel: [81 141 70 77 10 198 127 24 45 199 198 45 44 233 144 75 133 42 95 143 247 74 38 201 156 47 160 22 141 237 171 195]
    channel.go:108: 
            Error Trace:    channel.go:108
                                        channel.go:112
                                        bob.go:44
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Received unexpected error:
                            channel update rejected by peer: unknown channel
                            perun.network/go-perun/client.newPeerRejectedError
                                /home/rmbrt/.go/src/perun.network/go-perun/client/proposal.go:738
                            perun.network/go-perun/client.(*Channel).updateGeneric
                                /home/rmbrt/.go/src/perun.network/go-perun/client/update.go:219
                            perun.network/go-perun/client.(*Channel).update
                                /home/rmbrt/.go/src/perun.network/go-perun/client/update.go:251
                            perun.network/go-perun/client.(*Channel).Update
                                /home/rmbrt/.go/src/perun.network/go-perun/client/update.go:156
                            perun.network/go-perun/client/test.(*paymentChannel).sendUpdate
                                /home/rmbrt/.go/src/perun.network/go-perun/client/test/channel.go:106
                            perun.network/go-perun/client/test.(*paymentChannel).sendTransfer
                                /home/rmbrt/.go/src/perun.network/go-perun/client/test/channel.go:112
                            perun.network/go-perun/client/test.(*Bob).exec
                                /home/rmbrt/.go/src/perun.network/go-perun/client/test/bob.go:44
                            perun.network/go-perun/client/test.(*Responder).Execute
                                /home/rmbrt/.go/src/perun.network/go-perun/client/test/responder.go:56
                            perun.network/go-perun/client/test.(*Bob).Execute
                                /home/rmbrt/.go/src/perun.network/go-perun/client/test/bob.go:35
                            perun.network/go-perun/backend/ethereum/client_test.TestHappyAliceBob.func1
                                /home/rmbrt/.go/src/perun.network/go-perun/backend/ethereum/client/happy_test.go:75
                            runtime.goexit
                                /usr/local/go/src/runtime/asm_amd64.s:1374
            Test:           TestHappyAliceBob
    channel.go:154: 
            Error Trace:    channel.go:154
                                        channel.go:120
                                        bob.go:44
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was -1
            Test:           TestHappyAliceBob
            Messages:       bal[0]: 100 != 103
    channel.go:155: 
            Error Trace:    channel.go:155
                                        channel.go:120
                                        bob.go:44
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was 1
            Test:           TestHappyAliceBob
            Messages:       bal[1]: 100 != 97
    channel.go:154: 
            Error Trace:    channel.go:154
                                        channel.go:120
                                        bob.go:44
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was -1
            Test:           TestHappyAliceBob
            Messages:       bal[0]: 103 != 106
    channel.go:155: 
            Error Trace:    channel.go:155
                                        channel.go:120
                                        bob.go:44
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was 1
            Test:           TestHappyAliceBob
            Messages:       bal[1]: 97 != 94
    channel.go:133: timeout: expected incoming channel update
    channel.go:154: 
            Error Trace:    channel.go:154
                                        channel.go:142
                                        bob.go:51
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was -1
            Test:           TestHappyAliceBob
            Messages:       bal[0]: 98 != 101
    channel.go:155: 
            Error Trace:    channel.go:155
                                        channel.go:142
                                        bob.go:51
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was 1
            Test:           TestHappyAliceBob
            Messages:       bal[1]: 102 != 99
    channel.go:154: 
            Error Trace:    channel.go:154
                                        channel.go:142
                                        bob.go:51
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was -1
            Test:           TestHappyAliceBob
            Messages:       bal[0]: 93 != 96
    channel.go:155: 
            Error Trace:    channel.go:155
                                        channel.go:142
                                        bob.go:51
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was 1
            Test:           TestHappyAliceBob
            Messages:       bal[1]: 107 != 104
    channel.go:154: 
            Error Trace:    channel.go:154
                                        channel.go:186
                                        channel.go:176
                                        bob.go:60
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was -1
            Test:           TestHappyAliceBob
            Messages:       bal[0]: 93 != 96
    channel.go:155: 
            Error Trace:    channel.go:155
                                        channel.go:186
                                        channel.go:176
                                        bob.go:60
                                        responder.go:56
                                        bob.go:35
                                        happy_test.go:75
                                        asm_amd64.s:1374
            Error:          Should be zero, but was 1
            Test:           TestHappyAliceBob
            Messages:       bal[1]: 107 != 104
    happy_test.go:92: 
            Error Trace:    happy_test.go:92
                                        happy_test.go:95
            Error:          Should be zero, but was 1
            Test:           TestHappyAliceBob
            Messages:       ETH balance mismatch
    happy_test.go:92: 
            Error Trace:    happy_test.go:92
                                        happy_test.go:96
            Error:          Should be zero, but was -1
            Test:           TestHappyAliceBob
            Messages:       ETH balance mismatch
ERRO[0009] TX failed; error determining reason: CallContract: simulatedBackend cannot access blocks other than the latest block 
WARN[0009] Calling conclude(Final) failed, waiting for event anyways...  error="calling conclude: mining transaction: transaction failed" txSender=0x3E98014840556d5eE8b8db2C924E63DAfdD9FB3D
FAIL
FAIL    perun.network/go-perun/backend/ethereum/client    9.607s

Proposal

Rewrite the tests to use ConcurrentT, stop using assert, switch to require instead, add more synchronisation points using ConcurrentT's barrier feature if needed.

RmbRT commented 2 years ago

This should have been fixed by #4. Investigate which case was missed by that PR.