test(wallet) add dev integration tests for incremental activity updates

Test used to investigate the deadlock caused by sending message while
in a message handler.
This commit is contained in:
Stefan 2023-12-16 22:18:20 -06:00 committed by Stefan Dunca
parent a55dcf299e
commit 40396dcf6f
9 changed files with 259 additions and 88 deletions

View File

@ -96,6 +96,7 @@ QtObject:
self.newDataAvailableFn()
# TODO #12120: Replace these specific events with incremental updates events
self.walletEventHandlers[EventNewTransfers] = newDataAvailableCallback
self.walletEventHandlers[EventPendingTransactionUpdate] = newDataAvailableCallback
self.walletEventHandlers[EventMTTransactionUpdate] = newDataAvailableCallback

View File

@ -20,11 +20,11 @@ Run wallet tests
- once
```sh
(cd test/status-go/integration && go test -v ./wallet/... --tags=gowaku_no_rln,gowaku_skip_migrations)
(cd test/status-go/integration && go test -count=1 -v ./wallet/... --tags=gowaku_no_rln,gowaku_skip_migrations)
```
- continuously on code changes
```sh
(cd test/status-go/integration && nodemon --watch ../../../vendor/status-go/ --watch . --ext "*.go,*.sql" --exec 'go test -v ./wallet/... --tags=gowaku_no_rln,gowaku_skip_migrations 2>&1 | tee ~/proj/tmp/status-go-tests.log || exit 1')
(cd test/status-go/integration && nodemon --watch ../../../vendor/status-go/ --watch . --ext "*.go,*.sql" --exec 'go test -count=1 -v ./wallet/... --tags=gowaku_no_rln,gowaku_skip_migrations 2>&1 | tee ~/proj/tmp/status-go-tests.log || exit 1')
```

View File

@ -7,7 +7,9 @@ replace github.com/status-im/status-desktop/test/status-go/integration => ./
replace github.com/status-im/status-go => ../../../vendor/status-go
// Keep these in sync with status-go/go.mod aliases
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/status-im/go-ethereum v1.10.25-status.11
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/status-im/go-ethereum v1.10.25-status.13
replace github.com/rjeczalik/notify => github.com/status-im/notify v1.0.2-status
replace github.com/docker/docker => github.com/docker/engine v1.4.2-0.20190717161051-705d9623b7c1
@ -25,6 +27,7 @@ require (
require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/PuerkitoBio/goquery v1.6.1 // indirect
github.com/RoaringBitmap/roaring v0.9.4 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
@ -126,6 +129,8 @@ require (
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/koron/go-ssdp v0.0.4 // indirect
github.com/ladydascalie/currency v1.6.0 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lib/pq v1.10.4 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
@ -222,6 +227,7 @@ require (
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 // indirect
github.com/status-im/markdown v0.0.0-20231114210825-6c2d15b5dc57 // indirect
github.com/status-im/migrate/v4 v4.6.2-status.3 // indirect
github.com/status-im/mvds v0.0.27-0.20240111144448-92d364e4be82 // indirect
github.com/status-im/rendezvous v1.3.7 // indirect
github.com/status-im/status-go/extkeys v1.1.2 // indirect
github.com/status-im/tcp-shaker v1.1.1-status // indirect
@ -233,10 +239,9 @@ require (
github.com/tsenart/tb v0.0.0-20181025101425-0d2499c8b6e9 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/urfave/cli/v2 v2.24.4 // indirect
github.com/vacp2p/mvds v0.0.24-0.20201124060106-26d8e94130d8 // indirect
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 // indirect
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 // indirect
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe // indirect
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873 // indirect
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 // indirect
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b // indirect
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230916171929-1dd9494ff065 // indirect

View File

@ -111,6 +111,8 @@ github.com/ClickHouse/clickhouse-go v1.4.3/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHg
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
@ -917,7 +919,6 @@ github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw
github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog=
github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-migrate/migrate/v4 v4.6.2/go.mod h1:JYi6reN3+Z734VZ0akNuyOJNcrg45ZL7LDBMW3WGJL0=
github.com/golang-migrate/migrate/v4 v4.15.2 h1:vU+M05vs6jWHKDdmE1Ecwj0BznygFc4QsdRe2E/L7kc=
github.com/golang-migrate/migrate/v4 v4.15.2/go.mod h1:f2toGLkYqD3JH+Todi4aZ2ZdbeUNx4sIwiOK96rE9Lw=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
@ -1323,6 +1324,10 @@ github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4F
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
github.com/ladydascalie/currency v1.6.0 h1:r5s/TMCYcpn6jPRHLV3F8nI7YjpY8trvstfuixxiHns=
github.com/ladydascalie/currency v1.6.0/go.mod h1:C9eil8e6tthhBb5yhwoH1U0LT5hm1BP/g+v/V82KYjY=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
@ -1544,7 +1549,6 @@ github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/n
github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU=
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mutecomm/go-sqlcipher v0.0.0-20190227152316-55dbde17881f/go.mod h1:MyUWrZlB1aI5bs7j9/pJ8ckLLZ4QcCYcNiSbsAW32D4=
github.com/mutecomm/go-sqlcipher/v4 v4.4.0/go.mod h1:PyN04SaWalavxRGH9E8ZftG6Ju7rsPrGmQRjrEaVpiY=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
@ -1855,10 +1859,6 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qq
github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=
github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM=
github.com/rjeczalik/notify v0.9.3 h1:6rJAzHTGKXGj76sbRgDiDcYj/HniypXmSJo1SWakZeY=
github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc=
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
@ -1981,8 +1981,8 @@ github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/y
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/status-im/doubleratchet v3.0.0+incompatible h1:aJ1ejcSERpSzmWZBgtfYtiU2nF0Q8ZkGyuEPYETXkCY=
github.com/status-im/doubleratchet v3.0.0+incompatible/go.mod h1:1sqR0+yhiM/bd+wrdX79AOt2csZuJOni0nUDzKNuqOU=
github.com/status-im/go-ethereum v1.10.25-status.11 h1:casDsgnrkXzyO9SQVyFsT+63XuInyFXzfEHRW/9eEVY=
github.com/status-im/go-ethereum v1.10.25-status.11/go.mod h1:Dt4K5JYMhJRdtXJwBEyGZLZn9iz/chSOZyjVmt5ZhwQ=
github.com/status-im/go-ethereum v1.10.25-status.13 h1:BIQB1MEY5m/D0pd4zXF1psKgyHMmnC+HZ+liJfB4tmY=
github.com/status-im/go-ethereum v1.10.25-status.13/go.mod h1:Dt4K5JYMhJRdtXJwBEyGZLZn9iz/chSOZyjVmt5ZhwQ=
github.com/status-im/go-multiaddr-ethv4 v1.2.5 h1:pN+ey6wYKbvNNu5/xq9+VL0N8Yq0pZUTbZp0URg+Yn4=
github.com/status-im/go-multiaddr-ethv4 v1.2.5/go.mod h1:Fhe/18yWU5QwlAYiOO3Bb1BLe0bn5YobcNBHsjRr4kk=
github.com/status-im/go-sqlcipher/v4 v4.5.4-status.2 h1:Oi9JTAI2DZEe5UKlpUcvKBCCSn3ULsLIrix7jPnEoPE=
@ -1994,9 +1994,12 @@ github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 h1:Oo2KZNP70K
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
github.com/status-im/markdown v0.0.0-20231114210825-6c2d15b5dc57 h1:AuJFXERIFVzUjf9rrTb8vamFubB6Ks/e8aUasDr4pOM=
github.com/status-im/markdown v0.0.0-20231114210825-6c2d15b5dc57/go.mod h1:5rjPyv3KffPNVbFjnsVy0NGj9+JeW40WvXLdxH1VKuE=
github.com/status-im/migrate/v4 v4.6.2-status.2/go.mod h1:c/kc90n47GZu/58nnz1OMLTf7uE4Da4gZP5qmU+A/v8=
github.com/status-im/migrate/v4 v4.6.2-status.3 h1:Khwjb59NzniloUr5i9s9AtkEyqBbQFt1lkoAu66sAu0=
github.com/status-im/migrate/v4 v4.6.2-status.3/go.mod h1:c/kc90n47GZu/58nnz1OMLTf7uE4Da4gZP5qmU+A/v8=
github.com/status-im/mvds v0.0.27-0.20240111144448-92d364e4be82 h1:A7jtwOlDMUGUPx5tTwUPewMoIprvo9oN9kU0H1CP+FQ=
github.com/status-im/mvds v0.0.27-0.20240111144448-92d364e4be82/go.mod h1:2fiAx0q9XYIPKYRq2B1oiO9zZESy/n4D32gWw6lMDsE=
github.com/status-im/notify v1.0.2-status h1:x8wev0Sh8H8KAf4bVcv+L0dVHldBESOKUlqRqRY7uL8=
github.com/status-im/notify v1.0.2-status/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc=
github.com/status-im/rendezvous v1.3.7 h1:rZGWsFCjPV3MWeUkLkZSOGTAvyRf+rxx5hnEGLE4OHg=
github.com/status-im/rendezvous v1.3.7/go.mod h1:r0vCbQJByTteMajN0f+Mcet/Vd7uAXxFPfewNpI2iXQ=
github.com/status-im/resize v0.0.0-20201215164250-7c6d9f0d3088 h1:ClCAP2FPCvl8hGMhbUx/tq/sOu2wibztAa5jAvQEe4Q=
@ -2026,7 +2029,6 @@ github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.3.1-0.20190712000136-221dbe5ed467/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@ -2077,8 +2079,6 @@ github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU=
github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/vacp2p/mvds v0.0.24-0.20201124060106-26d8e94130d8 h1:aSQuY64yglPb7I6lZRXt/xWD4ExM1DZo8Gpb7xCz6zk=
github.com/vacp2p/mvds v0.0.24-0.20201124060106-26d8e94130d8/go.mod h1:uUmtiahU7efOVl/5w5yk9jOze5xYpDZDrSrT8TvHXjQ=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
@ -2092,12 +2092,12 @@ github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmF
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 h1:xwY0kW5XZFimdqfZb9cZwT1S3VJP9j3AE6bdNd9boXM=
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 h1:Kk0KYXZE/uNnARF2TbCQyvyZ/w4SgF8VhquNdOVVsNU=
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe h1:2D97fbaKlIQRjWMz/iTjnYcxi2z6ekKvspTGtcuPHgU=
github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe/go.mod h1:+b5fPPJ4YUIAPJtPOtwB7bTrOQ9lF15I2LnQjV6NMIA=
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873 h1:pnUvFENjM/h7HVF8VsNWTmOXx/rYs62P7H2EFjAnwVw=
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873/go.mod h1:RjTvkTrIwpoT1cM9HeQqwa2Q7t7WOkb3hpuB/zuZ6SM=
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 h1:jisj+OCI6QydLtFq3Pyhu49wl9ytPN7oAHjMfepHDrA=
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59/go.mod h1:1PdBdPzyTaKt3VnpAHk3zj+r9dXPFOr3IHZP9nFle6E=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b h1:KgZVhsLkxsj5gb/FfndSCQu6VYwALrCOgYI3poR95yE=

View File

@ -16,6 +16,7 @@ import (
"github.com/status-im/status-go/multiaccounts"
"github.com/status-im/status-go/services/wallet/walletevent"
"github.com/status-im/status-go/signal"
"github.com/stretchr/testify/require"
)
type StatusGoEventName string
@ -88,6 +89,11 @@ func LoginToTestAccount(t *testing.T) (eventQueue chan GoEvent, config *Config,
return
}
func Logout(t *testing.T) {
err := logout()
require.NoError(t, err)
}
func WaitForEvent(eventQueue chan GoEvent, eventName StatusGoEventName, timeout time.Duration) (event *GoEvent, err error) {
for {
select {
@ -101,8 +107,14 @@ func WaitForEvent(eventQueue chan GoEvent, eventName StatusGoEventName, timeout
}
}
func WaitForWalletEvent[T any](eventQueue chan GoEvent, eventName walletevent.EventType, timeout time.Duration) (payload *T, err error) {
// WaitForWalletEvents returns payloads corresponding to the given eventNames in the order they are received for duplicate events
func WaitForWalletEvents[T any](eventQueue chan GoEvent, eventNamesOrig []walletevent.EventType, timeout time.Duration) (payloads []*T, err error) {
var event *GoEvent
payloads = make([]*T, len(eventNamesOrig))
processed := make([]bool, len(eventNamesOrig))
processedCount := 0
for {
event, err = WaitForEvent(eventQueue, WalletEvent, timeout)
if err != nil {
@ -115,18 +127,40 @@ func WaitForWalletEvent[T any](eventQueue chan GoEvent, eventName walletevent.Ev
}
var newPayload T
if walletEvent.Type == eventName {
foundIndex := -1
for i, eventName := range eventNamesOrig {
if walletEvent.Type == eventName && !processed[i] {
foundIndex = i
processed[i] = true
processedCount += 1
break
}
}
if foundIndex != -1 {
if walletEvent.Message != "" {
err = json.Unmarshal([]byte(walletEvent.Message), &newPayload)
if err != nil {
return nil, err
}
return &newPayload, nil
payloads[foundIndex] = &newPayload
} else {
payloads[foundIndex] = nil
}
return nil, nil
if processedCount == len(eventNamesOrig) {
return payloads, nil
}
}
}
}
func WaitForWalletEvent[T any](eventQueue chan GoEvent, eventName walletevent.EventType, timeout time.Duration) (payload *T, err error) {
res, err := WaitForWalletEvents[T](eventQueue, []walletevent.EventType{eventName}, timeout)
if err != nil {
return nil, err
}
return res[0], nil
}
func loginToAccount(hashedPassword, userFolder, nodeConfigJson string) error {
absUserFolder, err := filepath.Abs(userFolder)
@ -167,6 +201,20 @@ func loginToAccount(hashedPassword, userFolder, nodeConfigJson string) error {
return nil
}
func logout() error {
logoutJson := statusgo.Logout()
apiResponse := statusgo.APIResponse{}
err := GetCAPIResponse(logoutJson, &apiResponse)
if err != nil {
return err
}
if apiResponse.Error != "" {
return fmt.Errorf("API error: %s", apiResponse.Error)
}
return nil
}
type jsonrpcMessage struct {
Version string `json:"jsonrpc"`
ID json.RawMessage `json:"id"`
@ -179,7 +227,7 @@ type jsonrpcRequest struct {
Params json.RawMessage `json:"params,omitempty"`
}
func CallPrivateMethod(method string, params []interface{}) (string, error) {
func CallPrivateMethodWithTimeout(method string, params []interface{}, timeout time.Duration) (string, error) {
var paramsJson json.RawMessage
var err error
if params != nil {
@ -202,7 +250,31 @@ func CallPrivateMethod(method string, params []interface{}) (string, error) {
return "", err
}
return statusgo.CallPrivateRPC(string(msgJson)), nil
didTimeout := false
done := make(chan bool)
var responseJson string
go func() {
responseJson = statusgo.CallPrivateRPC(string(msgJson))
if didTimeout {
log.Warn("Call to CallPrivateRPC returned after timeout", "payload", string(msgJson))
return
}
done <- true
}()
select {
case <-done:
case <-time.After(timeout):
didTimeout = true
return "", fmt.Errorf("timeout waiting for response to statusgo.CallPrivateRPC; payload \"%s\"", string(msgJson))
}
return responseJson, nil
}
func CallPrivateMethod(method string, params []interface{}) (string, error) {
return CallPrivateMethodWithTimeout(method, params, 60*time.Second)
}
type Config struct {
@ -244,6 +316,7 @@ func processConfigArgs(configFilePath string) (config *Config, nodeConfigJson st
return
}
// GetCAPIResponse expects res to be a pointer to a struct, a pointer to a slice or a pointer to a map for marshaling
func GetCAPIResponse[T any](responseJson string, res T) error {
apiResponse := statusgo.APIResponse{}
err := json.Unmarshal([]byte(responseJson), &apiResponse)

View File

@ -0,0 +1,56 @@
// These tests are for development only to be run manually
// There is more work needed to automate them not to depend on an existing account and internet connection
package wallet
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/status-im/status-desktop/test/status-go/integration/helpers"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/services/wallet/activity"
"github.com/status-im/status-go/services/wallet/common"
"github.com/status-im/status-go/services/wallet/walletevent"
"github.com/status-im/status-go/transactions"
)
// TestActivityIncrementalUpdates_NoFilterNewPendingTransactions tests that a pending transaction is created, then updated and finally deleted.
func TestActivityIncrementalUpdates_NoFilterNewPendingTransactions(t *testing.T) {
td, close := setupAccountsAndTransactions(t)
defer close()
_, err := helpers.CallPrivateMethod("wallet_startActivityFilterSession", []interface{}{[]types.Address{td.sender.Address}, false, []common.ChainID{5}, activity.Filter{}, 3})
require.NoError(t, err)
// Confirm async filtering results
filterRes, err := helpers.WaitForWalletEvents[activity.FilterResponse](
td.eventQueue, []walletevent.EventType{activity.EventActivityFilteringDone},
5*time.Second,
)
require.NoError(t, err)
res := filterRes[0]
require.Equal(t, activity.ErrorCodeSuccess, res.ErrorCode)
require.Equal(t, 3, len(res.Activities))
// Trigger updating of activity results
sendTransaction(t, td)
// Wait for EventActivitySessionUpdated signal triggered by the EventPendingTransactionUpdate
update, err := helpers.WaitForWalletEvent[activity.SessionUpdate](td.eventQueue, activity.EventActivitySessionUpdated, 2*time.Second)
require.NoError(t, err)
require.Equal(t, 1, len(update.NewEntries))
// Step x: Trigger downloading of the new transaction ...
_, err = helpers.CallPrivateMethodWithTimeout("wallet_checkRecentHistoryForChainIDs", []interface{}{[]uint64{5}, []types.Address{td.sender.Address, td.recipient.Address}}, 2*time.Second)
require.NoError(t, err)
// ... and wait for the new transaction download to trigger deletion from pending_transactions
updatePayload, err := helpers.WaitForWalletEvent[transactions.PendingTxUpdatePayload](
td.eventQueue, transactions.EventPendingTransactionUpdate, 120*time.Second)
require.NoError(t, err)
require.Equal(t, true, updatePayload.Deleted)
}

View File

@ -0,0 +1,78 @@
package wallet
import (
"math/big"
"testing"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/status-im/status-desktop/test/status-go/integration/helpers"
"github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/services/wallet/bridge"
"github.com/status-im/status-go/services/wallet/transfer"
"github.com/status-im/status-go/transactions"
"github.com/stretchr/testify/require"
)
type testUserData struct {
sender accounts.Account
recipient accounts.Account
hashedPassword string
eventQueue chan helpers.GoEvent
}
func setupAccountsAndTransactions(t *testing.T) (td testUserData, close func()) {
eventQueue, conf, _ := helpers.LoginToTestAccount(t)
_, err := helpers.WaitForEvent(eventQueue, helpers.NodeReadyEvent, 60*time.Second)
require.NoError(t, err)
opAccounts, err := helpers.GetWalletOperableAccounts()
require.NoError(t, err)
require.Greater(t, len(opAccounts), 0)
watchAccounts, err := helpers.GetWalletWatchOnlyAccounts()
require.NoError(t, err)
require.Greater(t, len(watchAccounts), 0)
return testUserData{
opAccounts[0],
watchAccounts[0],
conf.HashedPassword,
eventQueue,
}, func() {
helpers.Logout(t)
}
}
// sendTransaction generates multi_transactions and pending entries then it creates and publishes a transaction
func sendTransaction(t *testing.T, td testUserData) {
mTCommand := transfer.MultiTransactionCommand{
FromAddress: common.Address(td.sender.Address),
ToAddress: common.Address(td.recipient.Address),
FromAsset: "ETH",
ToAsset: "ETH",
FromAmount: (*hexutil.Big)(new(big.Int).SetUint64(100000)),
Type: transfer.MultiTransactionSend,
}
data := []*bridge.TransactionBridge{
{
BridgeName: "Transfer",
ChainID: 5,
TransferTx: &transactions.SendTxArgs{
From: td.sender.Address,
To: &td.recipient.Address,
Value: (*hexutil.Big)(new(big.Int).Set(mTCommand.FromAmount.ToInt())),
},
},
}
sessionReqRes, err := helpers.CallPrivateMethod("wallet_createMultiTransaction", []interface{}{mTCommand, data, td.hashedPassword})
require.NoError(t, err)
var apiResponse *transfer.MultiTransactionCommandResult
err = helpers.GetRPCAPIResponse(sessionReqRes, &apiResponse)
require.NoError(t, err)
require.Equal(t, 1, len(apiResponse.Hashes))
}

View File

@ -4,82 +4,40 @@
package wallet
import (
"math/big"
"testing"
"time"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/common"
"github.com/status-im/status-desktop/test/status-go/integration/helpers"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/services/wallet/bridge"
"github.com/status-im/status-go/services/wallet/transfer"
"github.com/status-im/status-go/services/wallet/walletevent"
"github.com/status-im/status-go/transactions"
)
// TestPendingTx_NotificationStatus tests that a pending transaction is created, then updated and finally deleted.
func TestPendingTx_NotificationStatus(t *testing.T) {
eventQueue, conf, _ := helpers.LoginToTestAccount(t)
td, close := setupAccountsAndTransactions(t)
defer close()
_, err := helpers.WaitForEvent(eventQueue, helpers.NodeReadyEvent, 60*time.Second)
require.NoError(t, err)
sendTransaction(t, td)
opAccounts, err := helpers.GetWalletOperableAccounts()
require.NoError(t, err)
require.Greater(t, len(opAccounts), 0)
sender := opAccounts[0]
watchAccounts, err := helpers.GetWalletWatchOnlyAccounts()
require.NoError(t, err)
require.Greater(t, len(watchAccounts), 0)
recipient := watchAccounts[0]
mTCommand := transfer.MultiTransactionCommand{
FromAddress: common.Address(sender.Address),
ToAddress: common.Address(recipient.Address),
FromAsset: "ETH",
ToAsset: "ETH",
FromAmount: (*hexutil.Big)(new(big.Int).SetUint64(100000)),
Type: transfer.MultiTransactionSend,
}
data := []*bridge.TransactionBridge{
{
BridgeName: "Transfer",
ChainID: 5,
TransferTx: &transactions.SendTxArgs{
From: sender.Address,
To: &recipient.Address,
Value: (*hexutil.Big)(new(big.Int).Set(mTCommand.FromAmount.ToInt())),
},
},
}
password := conf.HashedPassword
// Step 1: send a transaction that will generate a pending entry
sessionReqRes, err := helpers.CallPrivateMethod("wallet_createMultiTransaction", []interface{}{mTCommand, data, password})
require.NoError(t, err)
var apiResponse *transfer.MultiTransactionCommandResult
err = helpers.GetRPCAPIResponse(sessionReqRes, &apiResponse)
require.NoError(t, err)
require.Equal(t, 1, len(apiResponse.Hashes))
// Step 2: wait for the pending entry to be confirmed
statusPayload, err := helpers.WaitForWalletEvent[transactions.StatusChangedPayload](eventQueue, transactions.EventPendingTransactionStatusChanged, 60*time.Second)
require.NoError(t, err)
require.Equal(t, statusPayload.Status, transactions.Success)
// Step 3: Trigger downloading of the new transaction ...
_, err = helpers.CallPrivateMethod("wallet_checkRecentHistoryForChainIDs", []interface{}{[]uint64{5}, []types.Address{sender.Address, recipient.Address}})
// Start history download ...
_, err := helpers.CallPrivateMethod("wallet_checkRecentHistoryForChainIDs", []interface{}{[]uint64{5}, []types.Address{td.sender.Address, td.recipient.Address}})
require.NoError(t, err)
// ... and wait for the new transaction download to trigger deletion from pending_transactions
updatePayload, err := helpers.WaitForWalletEvent[transactions.PendingTxUpdatePayload](eventQueue, transactions.EventPendingTransactionUpdate, 60*time.Second)
updatePayloads, err := helpers.WaitForWalletEvents[transactions.PendingTxUpdatePayload](
td.eventQueue, []walletevent.EventType{
transactions.EventPendingTransactionUpdate,
transactions.EventPendingTransactionUpdate,
},
60*time.Second,
)
require.NoError(t, err)
require.True(t, updatePayload.Deleted)
// Validate that we received both add and delete event
require.False(t, updatePayloads[0].Deleted)
require.True(t, updatePayloads[1].Deleted)
}

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 0c2a93557884e608327c7d43d3c1b08e8aac0b41
Subproject commit 812910f087e0451cc702d2590cec3953bb8c3d14