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

Failing unit tests #395

Closed janbormet closed 6 months ago

janbormet commented 8 months ago

Location

TestAppRandomizerSet in channel/test/app_randomizer_internal_test.go and TestDialer_Dial, happy case in wire/net/simple/dialer_internal_test.go

Problem

There seem to be two failing unit tests. Apparently they do not fail in the CI nor for some of the maintainers, so there might be a race? These are the error traces (from go test ./... --count=1 in content root):

TestAppRandomizerSet

pkg/test: using rootSeed 1705672702804719252
--- FAIL: TestAppRandomizerSet (0.00s)
    app_randomizer_internal_test.go:35: 
                Error Trace:    app_randomizer_internal_test.go:35
                Error:          Should be false
                Test:           TestAppRandomizerSet
                Messages:       appRandomizer should have changed
FAIL
FAIL    perun.network/go-perun/channel/test     0.004s

TestDialer_Dial

pkg/test: using rootSeed 1705672703035073752
--- FAIL: TestDialer_Dial (0.00s)
    --- FAIL: TestDialer_Dial/happy (0.00s)
        dialer_internal_test.go:88: 
                Error Trace:    dialer_internal_test.go:88
                                                        concurrent.go:223
                                                        goexit.go:90
                                                        goexit.go:92
                                                        asm_amd64.s:1650
                Error:          Not equal: 
                                expected: &wire.Envelope{Sender:(*simple.Address)(0xc000206030), Recipient:(*simple.Address)(0xc000206040), Msg:(*wire.PingMsg)(0xc00021c018)}
                                actual  : &wire.Envelope{Sender:(*wire.Address)(0xc000022480), Recipient:(*wire.Address)(0xc0000223e0), Msg:(*wire.PingMsg)(0xc0000125e8)}

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,4 +1,10 @@
                                 (*wire.Envelope)({
                                - Sender: (*simple.Address)((len=32) "\x98\xcf\\\xa4{\xd6x\xceS\x18\x1d\xe8>E\x91\xfcJȞDv\xf6\x8f\xad\x9a\xbaSՂӿ\x93"),
                                - Recipient: (*simple.Address)((len=32) "\xa1\u0379\xa7w\xc9\xce\xcau\xb2\\az\x8d8]\xb6\xc3\xfd\xe1\xf7\xf7\x93\x92ؽR!՜\xb2\x93"),
                                + Sender: (*wire.Address)((len=32) {
                                +  00000000  98 cf 5c a4 7b d6 78 ce  53 18 1d e8 3e 45 91 fc  |..\.{.x.S...>E..|
                                +  00000010  4a c8 9e 44 76 f6 8f ad  9a ba 53 d5 82 d3 bf 93  |J..Dv.....S.....|
                                + }),
                                + Recipient: (*wire.Address)((len=32) {
                                +  00000000  a1 cd b9 a7 77 c9 ce ca  75 b2 5c 61 7a 8d 38 5d  |....w...u.\az.8]|
                                +  00000010  b6 c3 fd e1 f7 f7 93 92  d8 bd 52 21 d5 9c b2 93  |..........R!....|
                                + }),
                                  Msg: (*wire.PingMsg)({
                Test:           TestDialer_Dial/happy
FAIL
FAIL    perun.network/go-perun/wire/net/simple  0.104s

Proposal

First, find out why the errors do not occur in the CI, then fix.

RmbRT commented 8 months ago

the simple wire package sets wire.NewAddressFunc, but also imports backend/sim/wire, which also calls that function. Go 1.21 changed / clarified the order in which init() gets called. Why do backends have their own wire address? Or does only the sim backend have one?

Either throw out the sim backend's wire package or if that's required, just directly use that type instead of the simple.Address type. But I think if simple has an address, then sim backend should not have one. Or change the dialer test to be package simple_test.

iljabvh commented 6 months ago

Issue has been fixed in #399.