perun-network / perun-eth-mobile

:iphone: Mobile bindings for two-party-payment channels on Ethereum using go-perun.
https://perun.network/
Apache License 2.0
5 stars 3 forks source link

Add Go test CI #11

Open sebastianst opened 4 years ago

sebastianst commented 4 years ago

We should write a Go test (TestClient) for the prnm package:

First we need to setup a CI config

Then the test itself

  1. Create two fixed configurations for two test roles Alice and Bob (either as (alice|bob).json in directory testdata using Go's native JSON unmarshaling, or as fixed vars of type *Config).
  2. Start a ganache-cli with os.Exec and a fixed mnemonic (-m).
    • Set alice's and bob's account in 1. to two accounts from the ones being created with this mnemonic. (only needs to be done once while doing this)
    • parse the output of this os.Exec until the test blockchain is setup
  3. Start two go routines for alice and bob (see also go-perun's client/happy_test.go)
    • both create client from config
    • one of them deploys the contracts
    • alice adds bob as a remote peer (AddPeer)
    • alice proposes a channel to bob
    • bob accepts
    • both send TXs back and forth
    • one sends a finalization request
    • both settle the channel
    • channel and client are Close()d.
  4. Perform balance assertions, similar to happy_test.go.
ggwpez commented 4 years ago

First step would be to automatically generate the bindings, i created a Dockerfile with Android SDK+NDK, go and go-mobile. It is also currently building the bindings as example.
Still have to figure out how to get it all together.

ggwpez commented 4 years ago

Somehow the unit tests do not run when linked with the prnm.aar file.
https://github.com/golang/go/issues/35403 mentions this, not sure if i can fix it.

PS: Only the pure Java tests seem to be affected. Instrumentation tests on the Android Emulator work.