diff --git a/config.md b/config.md index a5d27d22..e83b9d84 100644 --- a/config.md +++ b/config.md @@ -35,6 +35,7 @@ |certFile|The path to the certificate file for TLS on this API|`string`|`` |clientAuth|Enables or disables client auth for TLS on this API|`string`|`` |enabled|Enables or disables TLS on this API|`boolean`|`false` +|insecureSkipHostVerify|When to true in unit test development environments to disable TLS verification. Use with extreme caution|`boolean`|`` |keyFile|The path to the private key file for TLS on this API|`string`|`` |requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`` @@ -100,6 +101,7 @@ |certFile|The path to the certificate file for TLS on this API|`string`|`` |clientAuth|Enables or disables client auth for TLS on this API|`string`|`` |enabled|Enables or disables TLS on this API|`boolean`|`false` +|insecureSkipHostVerify|When to true in unit test development environments to disable TLS verification. Use with extreme caution|`boolean`|`` |keyFile|The path to the private key file for TLS on this API|`string`|`` |requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`` @@ -194,6 +196,7 @@ |certFile|The path to the certificate file for TLS on this API|`string`|`` |clientAuth|Enables or disables client auth for TLS on this API|`string`|`` |enabled|Enables or disables TLS on this API|`boolean`|`false` +|insecureSkipHostVerify|When to true in unit test development environments to disable TLS verification. Use with extreme caution|`boolean`|`` |keyFile|The path to the private key file for TLS on this API|`string`|`` |requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`` @@ -260,6 +263,7 @@ |expectContinueTimeout|See [ExpectContinueTimeout in the Go docs](https://pkg.go.dev/net/http#Transport)|[`time.Duration`](https://pkg.go.dev/time#Duration)|`` |headers|Adds custom headers to HTTP requests|`map[string]string`|`` |idleTimeout|The max duration to hold a HTTP keepalive connection between calls|[`time.Duration`](https://pkg.go.dev/time#Duration)|`` +|maxConnsPerHost|The max number of connections, per unique hostname. Zero means no limit|`int`|`` |maxIdleConns|The max number of idle connections to hold pooled|`int`|`` |method|Deprecated: Please use 'transactions.handler.simple.gasOracle.method' instead|`string`|`` |mode|Deprecated: Please use 'transactions.handler.simple.gasOracle.mode' instead|'connector', 'restapi', 'fixed', or 'disabled'|`` @@ -289,6 +293,7 @@ |---|-----------|----|-------------| |count|The maximum number of times to retry|`int`|`` |enabled|Enables retries|`boolean`|`` +|errorStatusCodeRegex|The regex that the error response status code must match to trigger retry|`string`|`` |initWaitTime|The initial retry delay|[`time.Duration`](https://pkg.go.dev/time#Duration)|`` |maxWaitTime|The maximum retry delay|[`time.Duration`](https://pkg.go.dev/time#Duration)|`` @@ -300,6 +305,7 @@ |certFile|The path to the certificate file for TLS on this API|`string`|`` |clientAuth|Enables or disables client auth for TLS on this API|`string`|`` |enabled|Enables or disables TLS on this API|`boolean`|`` +|insecureSkipHostVerify|When to true in unit test development environments to disable TLS verification. Use with extreme caution|`boolean`|`` |keyFile|The path to the private key file for TLS on this API|`string`|`` |requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`` @@ -348,6 +354,7 @@ |expectContinueTimeout|See [ExpectContinueTimeout in the Go docs](https://pkg.go.dev/net/http#Transport)|[`time.Duration`](https://pkg.go.dev/time#Duration)|`` |headers|Adds custom headers to HTTP requests|`map[string]string`|`` |idleTimeout|The max duration to hold a HTTP keepalive connection between calls|[`time.Duration`](https://pkg.go.dev/time#Duration)|`` +|maxConnsPerHost|The max number of connections, per unique hostname. Zero means no limit|`int`|`` |maxIdleConns|The max number of idle connections to hold pooled|`int`|`` |method|The HTTP Method to use when invoking the Gas Oracle REST API|`string`|`` |mode|The gas oracle mode|'connector', 'restapi', 'fixed', or 'disabled'|`` @@ -377,6 +384,7 @@ |---|-----------|----|-------------| |count|The maximum number of times to retry|`int`|`` |enabled|Enables retries|`boolean`|`` +|errorStatusCodeRegex|The regex that the error response status code must match to trigger retry|`string`|`` |initWaitTime|The initial retry delay|[`time.Duration`](https://pkg.go.dev/time#Duration)|`` |maxWaitTime|The maximum retry delay|[`time.Duration`](https://pkg.go.dev/time#Duration)|`` @@ -388,6 +396,7 @@ |certFile|The path to the certificate file for TLS on this API|`string`|`` |clientAuth|Enables or disables client auth for TLS on this API|`string`|`` |enabled|Enables or disables TLS on this API|`boolean`|`` +|insecureSkipHostVerify|When to true in unit test development environments to disable TLS verification. Use with extreme caution|`boolean`|`` |keyFile|The path to the private key file for TLS on this API|`string`|`` |requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`` @@ -408,6 +417,7 @@ |expectContinueTimeout|See [ExpectContinueTimeout in the Go docs](https://pkg.go.dev/net/http#Transport)|[`time.Duration`](https://pkg.go.dev/time#Duration)|`1s` |headers|Adds custom headers to HTTP requests|`map[string]string`|`` |idleTimeout|The max duration to hold a HTTP keepalive connection between calls|[`time.Duration`](https://pkg.go.dev/time#Duration)|`475ms` +|maxConnsPerHost|The max number of connections, per unique hostname. Zero means no limit|`int`|`0` |maxIdleConns|The max number of idle connections to hold pooled|`int`|`100` |passthroughHeadersEnabled|Enable passing through the set of allowed HTTP request headers|`boolean`|`false` |requestTimeout|The maximum amount of time that a request is allowed to remain open|[`time.Duration`](https://pkg.go.dev/time#Duration)|`30s` @@ -432,6 +442,7 @@ |---|-----------|----|-------------| |count|The maximum number of times to retry|`int`|`5` |enabled|Enables retries|`boolean`|`false` +|errorStatusCodeRegex|The regex that the error response status code must match to trigger retry|`string`|`` |initWaitTime|The initial retry delay|[`time.Duration`](https://pkg.go.dev/time#Duration)|`250ms` |maxWaitTime|The maximum retry delay|[`time.Duration`](https://pkg.go.dev/time#Duration)|`30s` @@ -443,5 +454,6 @@ |certFile|The path to the certificate file for TLS on this API|`string`|`` |clientAuth|Enables or disables client auth for TLS on this API|`string`|`` |enabled|Enables or disables TLS on this API|`boolean`|`false` +|insecureSkipHostVerify|When to true in unit test development environments to disable TLS verification. Use with extreme caution|`boolean`|`` |keyFile|The path to the private key file for TLS on this API|`string`|`` |requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`` \ No newline at end of file diff --git a/go.mod b/go.mod index fe8bb898..bf519eaf 100644 --- a/go.mod +++ b/go.mod @@ -7,13 +7,12 @@ require ( github.com/Masterminds/sprig/v3 v3.2.2 github.com/Masterminds/squirrel v1.5.4 github.com/getkin/kin-openapi v0.116.0 - github.com/ghodss/yaml v1.0.0 github.com/go-resty/resty/v2 v2.7.0 github.com/golang-migrate/migrate/v4 v4.16.1 github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.5.0 github.com/hashicorp/golang-lru/v2 v2.0.3 - github.com/hyperledger/firefly-common v1.2.18 + github.com/hyperledger/firefly-common v1.4.1 github.com/lib/pq v1.10.9 github.com/oklog/ulid/v2 v2.1.0 github.com/prometheus/client_golang v1.13.0 @@ -21,15 +20,17 @@ require ( github.com/spf13/viper v1.14.0 github.com/stretchr/testify v1.8.1 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - golang.org/x/text v0.9.0 + golang.org/x/text v0.14.0 ) require ( + github.com/ghodss/yaml v1.0.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect + github.com/mattn/go-sqlite3 v1.14.16 // indirect github.com/perimeterx/marshmallow v1.1.4 // indirect gitlab.com/hfuss/mux-prometheus v0.0.5 // indirect go.uber.org/atomic v1.10.0 // indirect @@ -83,14 +84,13 @@ require ( github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/term v0.8.0 // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gotest.tools/v3 v3.1.0 // indirect ) diff --git a/go.sum b/go.sum index ffa68d71..6753f064 100644 --- a/go.sum +++ b/go.sum @@ -206,8 +206,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.3.1 h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/hyperledger/firefly-common v1.2.18 h1:oMxmhVsVhitoEeZXJPVIM10RxwK0Z33GeR+VPXxULms= -github.com/hyperledger/firefly-common v1.2.18/go.mod h1:17lOH4YufiPy82LpKm8fPa/YXJ0pUyq01zK1CmklJwM= +github.com/hyperledger/firefly-common v1.4.1 h1:ZhEsEQonzOHIUnHeEm+z8hq5BIQIVy1c41kVTjhblRM= +github.com/hyperledger/firefly-common v1.4.1/go.mod h1:wbhklt6aNEs3cEQjNEf3NZXOnB5pz0f2gxRh6S9rBmg= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= @@ -257,6 +257,7 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= +github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= @@ -355,7 +356,6 @@ github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU= @@ -407,8 +407,8 @@ golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -483,8 +483,8 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -560,12 +560,12 @@ golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -574,8 +574,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -749,7 +749,6 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools/v3 v3.1.0 h1:rVV8Tcg/8jHUkPUorwjaMTtemIMVXfIPKiOqnhEhakk= -gotest.tools/v3 v3.1.0/go.mod h1:fHy7eyTmJFO5bQbUsEGQ1v4m2J3Jz9eWL54TP2/ZuYQ= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/persistence/dbmigration/leveldb2postgres_test.go b/internal/persistence/dbmigration/leveldb2postgres_test.go index 85a4645f..c55065a6 100644 --- a/internal/persistence/dbmigration/leveldb2postgres_test.go +++ b/internal/persistence/dbmigration/leveldb2postgres_test.go @@ -20,7 +20,6 @@ import ( "context" "database/sql" "fmt" - "io/ioutil" "os" "path" "testing" @@ -95,7 +94,7 @@ func TestMigrateLevelDBToPostgres(t *testing.T) { defer done() // Configure a test LevelDB - dir, err := ioutil.TempDir("", "ldb_*") + dir, err := os.MkdirTemp("", "ldb_*") assert.NoError(t, err) config.Set(tmconfig.PersistenceLevelDBPath, dir) @@ -109,7 +108,7 @@ func TestMigrateLevelDBToPostgresFailPSQL(t *testing.T) { tmconfig.Reset() // Configure a test LevelDB - dir, err := ioutil.TempDir("", "ldb_*") + dir, err := os.MkdirTemp("", "ldb_*") assert.NoError(t, err) config.Set(tmconfig.PersistenceLevelDBPath, dir) diff --git a/internal/persistence/leveldb/leveldb_persistence_test.go b/internal/persistence/leveldb/leveldb_persistence_test.go index 0d50fc07..0cede9da 100644 --- a/internal/persistence/leveldb/leveldb_persistence_test.go +++ b/internal/persistence/leveldb/leveldb_persistence_test.go @@ -39,7 +39,7 @@ func newTestLevelDBPersistence(t *testing.T) (context.Context, *leveldbPersisten ctx, cancelCtx := context.WithCancel(context.Background()) - dir, err := ioutil.TempDir("", "ldb_*") + dir, err := os.MkdirTemp("", "ldb_*") assert.NoError(t, err) tmconfig.Reset() diff --git a/mocks/apiclientmocks/fftm_client.go b/mocks/apiclientmocks/fftm_client.go index 3b005d94..34122059 100644 --- a/mocks/apiclientmocks/fftm_client.go +++ b/mocks/apiclientmocks/fftm_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package apiclientmocks @@ -19,6 +19,10 @@ type FFTMClient struct { func (_m *FFTMClient) DeleteEventStream(ctx context.Context, eventStreamID string) error { ret := _m.Called(ctx, eventStreamID) + if len(ret) == 0 { + panic("no return value specified for DeleteEventStream") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { r0 = rf(ctx, eventStreamID) @@ -33,6 +37,10 @@ func (_m *FFTMClient) DeleteEventStream(ctx context.Context, eventStreamID strin func (_m *FFTMClient) DeleteEventStreamsByName(ctx context.Context, nameRegex string) error { ret := _m.Called(ctx, nameRegex) + if len(ret) == 0 { + panic("no return value specified for DeleteEventStreamsByName") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { r0 = rf(ctx, nameRegex) @@ -47,6 +55,10 @@ func (_m *FFTMClient) DeleteEventStreamsByName(ctx context.Context, nameRegex st func (_m *FFTMClient) DeleteListener(ctx context.Context, eventStreamID string, listenerID string) error { ret := _m.Called(ctx, eventStreamID, listenerID) + if len(ret) == 0 { + panic("no return value specified for DeleteListener") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { r0 = rf(ctx, eventStreamID, listenerID) @@ -61,6 +73,10 @@ func (_m *FFTMClient) DeleteListener(ctx context.Context, eventStreamID string, func (_m *FFTMClient) DeleteListenersByName(ctx context.Context, eventStreamID string, nameRegex string) error { ret := _m.Called(ctx, eventStreamID, nameRegex) + if len(ret) == 0 { + panic("no return value specified for DeleteListenersByName") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { r0 = rf(ctx, eventStreamID, nameRegex) @@ -75,6 +91,10 @@ func (_m *FFTMClient) DeleteListenersByName(ctx context.Context, eventStreamID s func (_m *FFTMClient) GetEventStreams(ctx context.Context) ([]apitypes.EventStream, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetEventStreams") + } + var r0 []apitypes.EventStream var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]apitypes.EventStream, error)); ok { @@ -101,6 +121,10 @@ func (_m *FFTMClient) GetEventStreams(ctx context.Context) ([]apitypes.EventStre func (_m *FFTMClient) GetListeners(ctx context.Context, eventStreamID string) ([]apitypes.Listener, error) { ret := _m.Called(ctx, eventStreamID) + if len(ret) == 0 { + panic("no return value specified for GetListeners") + } + var r0 []apitypes.Listener var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) ([]apitypes.Listener, error)); ok { diff --git a/mocks/confirmationsmocks/manager.go b/mocks/confirmationsmocks/manager.go index 86265c8d..48f14ff0 100644 --- a/mocks/confirmationsmocks/manager.go +++ b/mocks/confirmationsmocks/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package confirmationsmocks @@ -20,6 +20,10 @@ type Manager struct { func (_m *Manager) CheckInFlight(listenerID *fftypes.UUID) bool { ret := _m.Called(listenerID) + if len(ret) == 0 { + panic("no return value specified for CheckInFlight") + } + var r0 bool if rf, ok := ret.Get(0).(func(*fftypes.UUID) bool); ok { r0 = rf(listenerID) @@ -34,6 +38,10 @@ func (_m *Manager) CheckInFlight(listenerID *fftypes.UUID) bool { func (_m *Manager) NewBlockHashes() chan<- *ffcapi.BlockHashEvent { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for NewBlockHashes") + } + var r0 chan<- *ffcapi.BlockHashEvent if rf, ok := ret.Get(0).(func() chan<- *ffcapi.BlockHashEvent); ok { r0 = rf() @@ -50,6 +58,10 @@ func (_m *Manager) NewBlockHashes() chan<- *ffcapi.BlockHashEvent { func (_m *Manager) Notify(n *confirmations.Notification) error { ret := _m.Called(n) + if len(ret) == 0 { + panic("no return value specified for Notify") + } + var r0 error if rf, ok := ret.Get(0).(func(*confirmations.Notification) error); ok { r0 = rf(n) diff --git a/mocks/eventsmocks/stream.go b/mocks/eventsmocks/stream.go index ddc74e87..469121f9 100644 --- a/mocks/eventsmocks/stream.go +++ b/mocks/eventsmocks/stream.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package eventsmocks @@ -21,6 +21,10 @@ type Stream struct { func (_m *Stream) AddOrUpdateListener(ctx context.Context, id *fftypes.UUID, updates *apitypes.Listener, reset bool) (*apitypes.Listener, error) { ret := _m.Called(ctx, id, updates, reset) + if len(ret) == 0 { + panic("no return value specified for AddOrUpdateListener") + } + var r0 *apitypes.Listener var r1 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID, *apitypes.Listener, bool) (*apitypes.Listener, error)); ok { @@ -47,6 +51,10 @@ func (_m *Stream) AddOrUpdateListener(ctx context.Context, id *fftypes.UUID, upd func (_m *Stream) Delete(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Delete") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -61,6 +69,10 @@ func (_m *Stream) Delete(ctx context.Context) error { func (_m *Stream) RemoveListener(ctx context.Context, id *fftypes.UUID) error { ret := _m.Called(ctx, id) + if len(ret) == 0 { + panic("no return value specified for RemoveListener") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID) error); ok { r0 = rf(ctx, id) @@ -75,6 +87,10 @@ func (_m *Stream) RemoveListener(ctx context.Context, id *fftypes.UUID) error { func (_m *Stream) Spec() *apitypes.EventStream { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Spec") + } + var r0 *apitypes.EventStream if rf, ok := ret.Get(0).(func() *apitypes.EventStream); ok { r0 = rf() @@ -91,6 +107,10 @@ func (_m *Stream) Spec() *apitypes.EventStream { func (_m *Stream) Start(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -105,6 +125,10 @@ func (_m *Stream) Start(ctx context.Context) error { func (_m *Stream) Status() apitypes.EventStreamStatus { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Status") + } + var r0 apitypes.EventStreamStatus if rf, ok := ret.Get(0).(func() apitypes.EventStreamStatus); ok { r0 = rf() @@ -119,6 +143,10 @@ func (_m *Stream) Status() apitypes.EventStreamStatus { func (_m *Stream) Stop(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Stop") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -133,6 +161,10 @@ func (_m *Stream) Stop(ctx context.Context) error { func (_m *Stream) UpdateSpec(ctx context.Context, updates *apitypes.EventStream) error { ret := _m.Called(ctx, updates) + if len(ret) == 0 { + panic("no return value specified for UpdateSpec") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.EventStream) error); ok { r0 = rf(ctx, updates) diff --git a/mocks/ffcapimocks/api.go b/mocks/ffcapimocks/api.go index 07d15f5e..32aaf476 100644 --- a/mocks/ffcapimocks/api.go +++ b/mocks/ffcapimocks/api.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package ffcapimocks @@ -18,6 +18,10 @@ type API struct { func (_m *API) AddressBalance(ctx context.Context, req *ffcapi.AddressBalanceRequest) (*ffcapi.AddressBalanceResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for AddressBalance") + } + var r0 *ffcapi.AddressBalanceResponse var r1 ffcapi.ErrorReason var r2 error @@ -51,6 +55,10 @@ func (_m *API) AddressBalance(ctx context.Context, req *ffcapi.AddressBalanceReq func (_m *API) BlockInfoByHash(ctx context.Context, req *ffcapi.BlockInfoByHashRequest) (*ffcapi.BlockInfoByHashResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for BlockInfoByHash") + } + var r0 *ffcapi.BlockInfoByHashResponse var r1 ffcapi.ErrorReason var r2 error @@ -84,6 +92,10 @@ func (_m *API) BlockInfoByHash(ctx context.Context, req *ffcapi.BlockInfoByHashR func (_m *API) BlockInfoByNumber(ctx context.Context, req *ffcapi.BlockInfoByNumberRequest) (*ffcapi.BlockInfoByNumberResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for BlockInfoByNumber") + } + var r0 *ffcapi.BlockInfoByNumberResponse var r1 ffcapi.ErrorReason var r2 error @@ -117,6 +129,10 @@ func (_m *API) BlockInfoByNumber(ctx context.Context, req *ffcapi.BlockInfoByNum func (_m *API) DeployContractPrepare(ctx context.Context, req *ffcapi.ContractDeployPrepareRequest) (*ffcapi.TransactionPrepareResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for DeployContractPrepare") + } + var r0 *ffcapi.TransactionPrepareResponse var r1 ffcapi.ErrorReason var r2 error @@ -150,6 +166,10 @@ func (_m *API) DeployContractPrepare(ctx context.Context, req *ffcapi.ContractDe func (_m *API) EventListenerAdd(ctx context.Context, req *ffcapi.EventListenerAddRequest) (*ffcapi.EventListenerAddResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for EventListenerAdd") + } + var r0 *ffcapi.EventListenerAddResponse var r1 ffcapi.ErrorReason var r2 error @@ -183,6 +203,10 @@ func (_m *API) EventListenerAdd(ctx context.Context, req *ffcapi.EventListenerAd func (_m *API) EventListenerHWM(ctx context.Context, req *ffcapi.EventListenerHWMRequest) (*ffcapi.EventListenerHWMResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for EventListenerHWM") + } + var r0 *ffcapi.EventListenerHWMResponse var r1 ffcapi.ErrorReason var r2 error @@ -216,6 +240,10 @@ func (_m *API) EventListenerHWM(ctx context.Context, req *ffcapi.EventListenerHW func (_m *API) EventListenerRemove(ctx context.Context, req *ffcapi.EventListenerRemoveRequest) (*ffcapi.EventListenerRemoveResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for EventListenerRemove") + } + var r0 *ffcapi.EventListenerRemoveResponse var r1 ffcapi.ErrorReason var r2 error @@ -249,6 +277,10 @@ func (_m *API) EventListenerRemove(ctx context.Context, req *ffcapi.EventListene func (_m *API) EventListenerVerifyOptions(ctx context.Context, req *ffcapi.EventListenerVerifyOptionsRequest) (*ffcapi.EventListenerVerifyOptionsResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for EventListenerVerifyOptions") + } + var r0 *ffcapi.EventListenerVerifyOptionsResponse var r1 ffcapi.ErrorReason var r2 error @@ -282,6 +314,10 @@ func (_m *API) EventListenerVerifyOptions(ctx context.Context, req *ffcapi.Event func (_m *API) EventStreamNewCheckpointStruct() ffcapi.EventListenerCheckpoint { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for EventStreamNewCheckpointStruct") + } + var r0 ffcapi.EventListenerCheckpoint if rf, ok := ret.Get(0).(func() ffcapi.EventListenerCheckpoint); ok { r0 = rf() @@ -298,6 +334,10 @@ func (_m *API) EventStreamNewCheckpointStruct() ffcapi.EventListenerCheckpoint { func (_m *API) EventStreamStart(ctx context.Context, req *ffcapi.EventStreamStartRequest) (*ffcapi.EventStreamStartResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for EventStreamStart") + } + var r0 *ffcapi.EventStreamStartResponse var r1 ffcapi.ErrorReason var r2 error @@ -331,6 +371,10 @@ func (_m *API) EventStreamStart(ctx context.Context, req *ffcapi.EventStreamStar func (_m *API) EventStreamStopped(ctx context.Context, req *ffcapi.EventStreamStoppedRequest) (*ffcapi.EventStreamStoppedResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for EventStreamStopped") + } + var r0 *ffcapi.EventStreamStoppedResponse var r1 ffcapi.ErrorReason var r2 error @@ -364,6 +408,10 @@ func (_m *API) EventStreamStopped(ctx context.Context, req *ffcapi.EventStreamSt func (_m *API) GasEstimate(ctx context.Context, req *ffcapi.TransactionInput) (*ffcapi.GasEstimateResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for GasEstimate") + } + var r0 *ffcapi.GasEstimateResponse var r1 ffcapi.ErrorReason var r2 error @@ -397,6 +445,10 @@ func (_m *API) GasEstimate(ctx context.Context, req *ffcapi.TransactionInput) (* func (_m *API) GasPriceEstimate(ctx context.Context, req *ffcapi.GasPriceEstimateRequest) (*ffcapi.GasPriceEstimateResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for GasPriceEstimate") + } + var r0 *ffcapi.GasPriceEstimateResponse var r1 ffcapi.ErrorReason var r2 error @@ -430,6 +482,10 @@ func (_m *API) GasPriceEstimate(ctx context.Context, req *ffcapi.GasPriceEstimat func (_m *API) IsLive(ctx context.Context) (*ffcapi.LiveResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for IsLive") + } + var r0 *ffcapi.LiveResponse var r1 ffcapi.ErrorReason var r2 error @@ -463,6 +519,10 @@ func (_m *API) IsLive(ctx context.Context) (*ffcapi.LiveResponse, ffcapi.ErrorRe func (_m *API) IsReady(ctx context.Context) (*ffcapi.ReadyResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for IsReady") + } + var r0 *ffcapi.ReadyResponse var r1 ffcapi.ErrorReason var r2 error @@ -496,6 +556,10 @@ func (_m *API) IsReady(ctx context.Context) (*ffcapi.ReadyResponse, ffcapi.Error func (_m *API) NewBlockListener(ctx context.Context, req *ffcapi.NewBlockListenerRequest) (*ffcapi.NewBlockListenerResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for NewBlockListener") + } + var r0 *ffcapi.NewBlockListenerResponse var r1 ffcapi.ErrorReason var r2 error @@ -529,6 +593,10 @@ func (_m *API) NewBlockListener(ctx context.Context, req *ffcapi.NewBlockListene func (_m *API) NextNonceForSigner(ctx context.Context, req *ffcapi.NextNonceForSignerRequest) (*ffcapi.NextNonceForSignerResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for NextNonceForSigner") + } + var r0 *ffcapi.NextNonceForSignerResponse var r1 ffcapi.ErrorReason var r2 error @@ -562,6 +630,10 @@ func (_m *API) NextNonceForSigner(ctx context.Context, req *ffcapi.NextNonceForS func (_m *API) QueryInvoke(ctx context.Context, req *ffcapi.QueryInvokeRequest) (*ffcapi.QueryInvokeResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for QueryInvoke") + } + var r0 *ffcapi.QueryInvokeResponse var r1 ffcapi.ErrorReason var r2 error @@ -595,6 +667,10 @@ func (_m *API) QueryInvoke(ctx context.Context, req *ffcapi.QueryInvokeRequest) func (_m *API) TransactionPrepare(ctx context.Context, req *ffcapi.TransactionPrepareRequest) (*ffcapi.TransactionPrepareResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for TransactionPrepare") + } + var r0 *ffcapi.TransactionPrepareResponse var r1 ffcapi.ErrorReason var r2 error @@ -628,6 +704,10 @@ func (_m *API) TransactionPrepare(ctx context.Context, req *ffcapi.TransactionPr func (_m *API) TransactionReceipt(ctx context.Context, req *ffcapi.TransactionReceiptRequest) (*ffcapi.TransactionReceiptResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for TransactionReceipt") + } + var r0 *ffcapi.TransactionReceiptResponse var r1 ffcapi.ErrorReason var r2 error @@ -661,6 +741,10 @@ func (_m *API) TransactionReceipt(ctx context.Context, req *ffcapi.TransactionRe func (_m *API) TransactionSend(ctx context.Context, req *ffcapi.TransactionSendRequest) (*ffcapi.TransactionSendResponse, ffcapi.ErrorReason, error) { ret := _m.Called(ctx, req) + if len(ret) == 0 { + panic("no return value specified for TransactionSend") + } + var r0 *ffcapi.TransactionSendResponse var r1 ffcapi.ErrorReason var r2 error diff --git a/mocks/metricsmocks/transaction_handler_metrics.go b/mocks/metricsmocks/transaction_handler_metrics.go index 47ba69ef..d9709e89 100644 --- a/mocks/metricsmocks/transaction_handler_metrics.go +++ b/mocks/metricsmocks/transaction_handler_metrics.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package metricsmocks diff --git a/mocks/persistencemocks/persistence.go b/mocks/persistencemocks/persistence.go index 3b529d06..2462d59c 100644 --- a/mocks/persistencemocks/persistence.go +++ b/mocks/persistencemocks/persistence.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package persistencemocks @@ -27,6 +27,10 @@ type Persistence struct { func (_m *Persistence) AddSubStatusAction(ctx context.Context, txID string, subStatus apitypes.TxSubStatus, action apitypes.TxAction, info *fftypes.JSONAny, err *fftypes.JSONAny) error { ret := _m.Called(ctx, txID, subStatus, action, info, err) + if len(ret) == 0 { + panic("no return value specified for AddSubStatusAction") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, apitypes.TxSubStatus, apitypes.TxAction, *fftypes.JSONAny, *fftypes.JSONAny) error); ok { r0 = rf(ctx, txID, subStatus, action, info, err) @@ -48,6 +52,10 @@ func (_m *Persistence) AddTransactionConfirmations(ctx context.Context, txID str _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for AddTransactionConfirmations") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, bool, ...*apitypes.Confirmation) error); ok { r0 = rf(ctx, txID, clearExisting, confirmations...) @@ -67,6 +75,10 @@ func (_m *Persistence) Close(ctx context.Context) { func (_m *Persistence) DeleteCheckpoint(ctx context.Context, streamID *fftypes.UUID) error { ret := _m.Called(ctx, streamID) + if len(ret) == 0 { + panic("no return value specified for DeleteCheckpoint") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID) error); ok { r0 = rf(ctx, streamID) @@ -81,6 +93,10 @@ func (_m *Persistence) DeleteCheckpoint(ctx context.Context, streamID *fftypes.U func (_m *Persistence) DeleteListener(ctx context.Context, listenerID *fftypes.UUID) error { ret := _m.Called(ctx, listenerID) + if len(ret) == 0 { + panic("no return value specified for DeleteListener") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID) error); ok { r0 = rf(ctx, listenerID) @@ -95,6 +111,10 @@ func (_m *Persistence) DeleteListener(ctx context.Context, listenerID *fftypes.U func (_m *Persistence) DeleteStream(ctx context.Context, streamID *fftypes.UUID) error { ret := _m.Called(ctx, streamID) + if len(ret) == 0 { + panic("no return value specified for DeleteStream") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID) error); ok { r0 = rf(ctx, streamID) @@ -109,6 +129,10 @@ func (_m *Persistence) DeleteStream(ctx context.Context, streamID *fftypes.UUID) func (_m *Persistence) DeleteTransaction(ctx context.Context, txID string) error { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for DeleteTransaction") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { r0 = rf(ctx, txID) @@ -123,6 +147,10 @@ func (_m *Persistence) DeleteTransaction(ctx context.Context, txID string) error func (_m *Persistence) GetCheckpoint(ctx context.Context, streamID *fftypes.UUID) (*apitypes.EventStreamCheckpoint, error) { ret := _m.Called(ctx, streamID) + if len(ret) == 0 { + panic("no return value specified for GetCheckpoint") + } + var r0 *apitypes.EventStreamCheckpoint var r1 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID) (*apitypes.EventStreamCheckpoint, error)); ok { @@ -149,6 +177,10 @@ func (_m *Persistence) GetCheckpoint(ctx context.Context, streamID *fftypes.UUID func (_m *Persistence) GetListener(ctx context.Context, listenerID *fftypes.UUID) (*apitypes.Listener, error) { ret := _m.Called(ctx, listenerID) + if len(ret) == 0 { + panic("no return value specified for GetListener") + } + var r0 *apitypes.Listener var r1 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID) (*apitypes.Listener, error)); ok { @@ -175,6 +207,10 @@ func (_m *Persistence) GetListener(ctx context.Context, listenerID *fftypes.UUID func (_m *Persistence) GetStream(ctx context.Context, streamID *fftypes.UUID) (*apitypes.EventStream, error) { ret := _m.Called(ctx, streamID) + if len(ret) == 0 { + panic("no return value specified for GetStream") + } + var r0 *apitypes.EventStream var r1 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID) (*apitypes.EventStream, error)); ok { @@ -201,6 +237,10 @@ func (_m *Persistence) GetStream(ctx context.Context, streamID *fftypes.UUID) (* func (_m *Persistence) GetTransactionByID(ctx context.Context, txID string) (*apitypes.ManagedTX, error) { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for GetTransactionByID") + } + var r0 *apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*apitypes.ManagedTX, error)); ok { @@ -227,6 +267,10 @@ func (_m *Persistence) GetTransactionByID(ctx context.Context, txID string) (*ap func (_m *Persistence) GetTransactionByIDWithStatus(ctx context.Context, txID string, history bool) (*apitypes.TXWithStatus, error) { ret := _m.Called(ctx, txID, history) + if len(ret) == 0 { + panic("no return value specified for GetTransactionByIDWithStatus") + } + var r0 *apitypes.TXWithStatus var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, bool) (*apitypes.TXWithStatus, error)); ok { @@ -253,6 +297,10 @@ func (_m *Persistence) GetTransactionByIDWithStatus(ctx context.Context, txID st func (_m *Persistence) GetTransactionByNonce(ctx context.Context, signer string, nonce *fftypes.FFBigInt) (*apitypes.ManagedTX, error) { ret := _m.Called(ctx, signer, nonce) + if len(ret) == 0 { + panic("no return value specified for GetTransactionByNonce") + } + var r0 *apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, *fftypes.FFBigInt) (*apitypes.ManagedTX, error)); ok { @@ -279,6 +327,10 @@ func (_m *Persistence) GetTransactionByNonce(ctx context.Context, signer string, func (_m *Persistence) GetTransactionConfirmations(ctx context.Context, txID string) ([]*apitypes.Confirmation, error) { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for GetTransactionConfirmations") + } + var r0 []*apitypes.Confirmation var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) ([]*apitypes.Confirmation, error)); ok { @@ -305,6 +357,10 @@ func (_m *Persistence) GetTransactionConfirmations(ctx context.Context, txID str func (_m *Persistence) GetTransactionReceipt(ctx context.Context, txID string) (*ffcapi.TransactionReceiptResponse, error) { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for GetTransactionReceipt") + } + var r0 *ffcapi.TransactionReceiptResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*ffcapi.TransactionReceiptResponse, error)); ok { @@ -331,6 +387,10 @@ func (_m *Persistence) GetTransactionReceipt(ctx context.Context, txID string) ( func (_m *Persistence) InsertTransactionPreAssignedNonce(ctx context.Context, tx *apitypes.ManagedTX) error { ret := _m.Called(ctx, tx) + if len(ret) == 0 { + panic("no return value specified for InsertTransactionPreAssignedNonce") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.ManagedTX) error); ok { r0 = rf(ctx, tx) @@ -345,6 +405,10 @@ func (_m *Persistence) InsertTransactionPreAssignedNonce(ctx context.Context, tx func (_m *Persistence) InsertTransactionWithNextNonce(ctx context.Context, tx *apitypes.ManagedTX, lookupNextNonce txhandler.NextNonceCallback) error { ret := _m.Called(ctx, tx, lookupNextNonce) + if len(ret) == 0 { + panic("no return value specified for InsertTransactionWithNextNonce") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.ManagedTX, txhandler.NextNonceCallback) error); ok { r0 = rf(ctx, tx, lookupNextNonce) @@ -359,6 +423,10 @@ func (_m *Persistence) InsertTransactionWithNextNonce(ctx context.Context, tx *a func (_m *Persistence) ListListenersByCreateTime(ctx context.Context, after *fftypes.UUID, limit int, dir txhandler.SortDirection) ([]*apitypes.Listener, error) { ret := _m.Called(ctx, after, limit, dir) + if len(ret) == 0 { + panic("no return value specified for ListListenersByCreateTime") + } + var r0 []*apitypes.Listener var r1 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID, int, txhandler.SortDirection) ([]*apitypes.Listener, error)); ok { @@ -385,6 +453,10 @@ func (_m *Persistence) ListListenersByCreateTime(ctx context.Context, after *fft func (_m *Persistence) ListStreamListenersByCreateTime(ctx context.Context, after *fftypes.UUID, limit int, dir txhandler.SortDirection, streamID *fftypes.UUID) ([]*apitypes.Listener, error) { ret := _m.Called(ctx, after, limit, dir, streamID) + if len(ret) == 0 { + panic("no return value specified for ListStreamListenersByCreateTime") + } + var r0 []*apitypes.Listener var r1 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID, int, txhandler.SortDirection, *fftypes.UUID) ([]*apitypes.Listener, error)); ok { @@ -411,6 +483,10 @@ func (_m *Persistence) ListStreamListenersByCreateTime(ctx context.Context, afte func (_m *Persistence) ListStreamsByCreateTime(ctx context.Context, after *fftypes.UUID, limit int, dir txhandler.SortDirection) ([]*apitypes.EventStream, error) { ret := _m.Called(ctx, after, limit, dir) + if len(ret) == 0 { + panic("no return value specified for ListStreamsByCreateTime") + } + var r0 []*apitypes.EventStream var r1 error if rf, ok := ret.Get(0).(func(context.Context, *fftypes.UUID, int, txhandler.SortDirection) ([]*apitypes.EventStream, error)); ok { @@ -437,6 +513,10 @@ func (_m *Persistence) ListStreamsByCreateTime(ctx context.Context, after *fftyp func (_m *Persistence) ListTransactionsByCreateTime(ctx context.Context, after *apitypes.ManagedTX, limit int, dir txhandler.SortDirection) ([]*apitypes.ManagedTX, error) { ret := _m.Called(ctx, after, limit, dir) + if len(ret) == 0 { + panic("no return value specified for ListTransactionsByCreateTime") + } + var r0 []*apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.ManagedTX, int, txhandler.SortDirection) ([]*apitypes.ManagedTX, error)); ok { @@ -463,6 +543,10 @@ func (_m *Persistence) ListTransactionsByCreateTime(ctx context.Context, after * func (_m *Persistence) ListTransactionsByNonce(ctx context.Context, signer string, after *fftypes.FFBigInt, limit int, dir txhandler.SortDirection) ([]*apitypes.ManagedTX, error) { ret := _m.Called(ctx, signer, after, limit, dir) + if len(ret) == 0 { + panic("no return value specified for ListTransactionsByNonce") + } + var r0 []*apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, *fftypes.FFBigInt, int, txhandler.SortDirection) ([]*apitypes.ManagedTX, error)); ok { @@ -489,6 +573,10 @@ func (_m *Persistence) ListTransactionsByNonce(ctx context.Context, signer strin func (_m *Persistence) ListTransactionsPending(ctx context.Context, afterSequenceID string, limit int, dir txhandler.SortDirection) ([]*apitypes.ManagedTX, error) { ret := _m.Called(ctx, afterSequenceID, limit, dir) + if len(ret) == 0 { + panic("no return value specified for ListTransactionsPending") + } + var r0 []*apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, int, txhandler.SortDirection) ([]*apitypes.ManagedTX, error)); ok { @@ -515,6 +603,10 @@ func (_m *Persistence) ListTransactionsPending(ctx context.Context, afterSequenc func (_m *Persistence) RichQuery() persistence.RichQuery { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for RichQuery") + } + var r0 persistence.RichQuery if rf, ok := ret.Get(0).(func() persistence.RichQuery); ok { r0 = rf() @@ -531,6 +623,10 @@ func (_m *Persistence) RichQuery() persistence.RichQuery { func (_m *Persistence) SetTransactionReceipt(ctx context.Context, txID string, receipt *ffcapi.TransactionReceiptResponse) error { ret := _m.Called(ctx, txID, receipt) + if len(ret) == 0 { + panic("no return value specified for SetTransactionReceipt") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, *ffcapi.TransactionReceiptResponse) error); ok { r0 = rf(ctx, txID, receipt) @@ -545,6 +641,10 @@ func (_m *Persistence) SetTransactionReceipt(ctx context.Context, txID string, r func (_m *Persistence) UpdateTransaction(ctx context.Context, txID string, updates *apitypes.TXUpdates) error { ret := _m.Called(ctx, txID, updates) + if len(ret) == 0 { + panic("no return value specified for UpdateTransaction") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, *apitypes.TXUpdates) error); ok { r0 = rf(ctx, txID, updates) @@ -559,6 +659,10 @@ func (_m *Persistence) UpdateTransaction(ctx context.Context, txID string, updat func (_m *Persistence) WriteCheckpoint(ctx context.Context, checkpoint *apitypes.EventStreamCheckpoint) error { ret := _m.Called(ctx, checkpoint) + if len(ret) == 0 { + panic("no return value specified for WriteCheckpoint") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.EventStreamCheckpoint) error); ok { r0 = rf(ctx, checkpoint) @@ -573,6 +677,10 @@ func (_m *Persistence) WriteCheckpoint(ctx context.Context, checkpoint *apitypes func (_m *Persistence) WriteListener(ctx context.Context, spec *apitypes.Listener) error { ret := _m.Called(ctx, spec) + if len(ret) == 0 { + panic("no return value specified for WriteListener") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.Listener) error); ok { r0 = rf(ctx, spec) @@ -587,6 +695,10 @@ func (_m *Persistence) WriteListener(ctx context.Context, spec *apitypes.Listene func (_m *Persistence) WriteStream(ctx context.Context, spec *apitypes.EventStream) error { ret := _m.Called(ctx, spec) + if len(ret) == 0 { + panic("no return value specified for WriteStream") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.EventStream) error); ok { r0 = rf(ctx, spec) diff --git a/mocks/persistencemocks/rich_query.go b/mocks/persistencemocks/rich_query.go index b2809388..eda54d70 100644 --- a/mocks/persistencemocks/rich_query.go +++ b/mocks/persistencemocks/rich_query.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package persistencemocks @@ -23,6 +23,10 @@ type RichQuery struct { func (_m *RichQuery) ListListeners(ctx context.Context, filter ffapi.AndFilter) ([]*apitypes.Listener, *ffapi.FilterResult, error) { ret := _m.Called(ctx, filter) + if len(ret) == 0 { + panic("no return value specified for ListListeners") + } + var r0 []*apitypes.Listener var r1 *ffapi.FilterResult var r2 error @@ -58,6 +62,10 @@ func (_m *RichQuery) ListListeners(ctx context.Context, filter ffapi.AndFilter) func (_m *RichQuery) ListStreamListeners(ctx context.Context, streamID *fftypes.UUID, filter ffapi.AndFilter) ([]*apitypes.Listener, *ffapi.FilterResult, error) { ret := _m.Called(ctx, streamID, filter) + if len(ret) == 0 { + panic("no return value specified for ListStreamListeners") + } + var r0 []*apitypes.Listener var r1 *ffapi.FilterResult var r2 error @@ -93,6 +101,10 @@ func (_m *RichQuery) ListStreamListeners(ctx context.Context, streamID *fftypes. func (_m *RichQuery) ListStreams(ctx context.Context, filter ffapi.AndFilter) ([]*apitypes.EventStream, *ffapi.FilterResult, error) { ret := _m.Called(ctx, filter) + if len(ret) == 0 { + panic("no return value specified for ListStreams") + } + var r0 []*apitypes.EventStream var r1 *ffapi.FilterResult var r2 error @@ -128,6 +140,10 @@ func (_m *RichQuery) ListStreams(ctx context.Context, filter ffapi.AndFilter) ([ func (_m *RichQuery) ListTransactionConfirmations(ctx context.Context, txID string, filter ffapi.AndFilter) ([]*apitypes.ConfirmationRecord, *ffapi.FilterResult, error) { ret := _m.Called(ctx, txID, filter) + if len(ret) == 0 { + panic("no return value specified for ListTransactionConfirmations") + } + var r0 []*apitypes.ConfirmationRecord var r1 *ffapi.FilterResult var r2 error @@ -163,6 +179,10 @@ func (_m *RichQuery) ListTransactionConfirmations(ctx context.Context, txID stri func (_m *RichQuery) ListTransactionHistory(ctx context.Context, txID string, filter ffapi.AndFilter) ([]*apitypes.TXHistoryRecord, *ffapi.FilterResult, error) { ret := _m.Called(ctx, txID, filter) + if len(ret) == 0 { + panic("no return value specified for ListTransactionHistory") + } + var r0 []*apitypes.TXHistoryRecord var r1 *ffapi.FilterResult var r2 error @@ -198,6 +218,10 @@ func (_m *RichQuery) ListTransactionHistory(ctx context.Context, txID string, fi func (_m *RichQuery) ListTransactions(ctx context.Context, filter ffapi.AndFilter) ([]*apitypes.ManagedTX, *ffapi.FilterResult, error) { ret := _m.Called(ctx, filter) + if len(ret) == 0 { + panic("no return value specified for ListTransactions") + } + var r0 []*apitypes.ManagedTX var r1 *ffapi.FilterResult var r2 error @@ -233,6 +257,10 @@ func (_m *RichQuery) ListTransactions(ctx context.Context, filter ffapi.AndFilte func (_m *RichQuery) NewConfirmationFilter(ctx context.Context) ffapi.FilterBuilder { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for NewConfirmationFilter") + } + var r0 ffapi.FilterBuilder if rf, ok := ret.Get(0).(func(context.Context) ffapi.FilterBuilder); ok { r0 = rf(ctx) @@ -249,6 +277,10 @@ func (_m *RichQuery) NewConfirmationFilter(ctx context.Context) ffapi.FilterBuil func (_m *RichQuery) NewListenerFilter(ctx context.Context) ffapi.FilterBuilder { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for NewListenerFilter") + } + var r0 ffapi.FilterBuilder if rf, ok := ret.Get(0).(func(context.Context) ffapi.FilterBuilder); ok { r0 = rf(ctx) @@ -265,6 +297,10 @@ func (_m *RichQuery) NewListenerFilter(ctx context.Context) ffapi.FilterBuilder func (_m *RichQuery) NewStreamFilter(ctx context.Context) ffapi.FilterBuilder { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for NewStreamFilter") + } + var r0 ffapi.FilterBuilder if rf, ok := ret.Get(0).(func(context.Context) ffapi.FilterBuilder); ok { r0 = rf(ctx) @@ -281,6 +317,10 @@ func (_m *RichQuery) NewStreamFilter(ctx context.Context) ffapi.FilterBuilder { func (_m *RichQuery) NewTransactionFilter(ctx context.Context) ffapi.FilterBuilder { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for NewTransactionFilter") + } + var r0 ffapi.FilterBuilder if rf, ok := ret.Get(0).(func(context.Context) ffapi.FilterBuilder); ok { r0 = rf(ctx) @@ -297,6 +337,10 @@ func (_m *RichQuery) NewTransactionFilter(ctx context.Context) ffapi.FilterBuild func (_m *RichQuery) NewTxHistoryFilter(ctx context.Context) ffapi.FilterBuilder { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for NewTxHistoryFilter") + } + var r0 ffapi.FilterBuilder if rf, ok := ret.Get(0).(func(context.Context) ffapi.FilterBuilder); ok { r0 = rf(ctx) diff --git a/mocks/persistencemocks/transaction_persistence.go b/mocks/persistencemocks/transaction_persistence.go index 81b736c8..9e15c8e8 100644 --- a/mocks/persistencemocks/transaction_persistence.go +++ b/mocks/persistencemocks/transaction_persistence.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package persistencemocks @@ -32,6 +32,10 @@ func (_m *TransactionPersistence) AddTransactionConfirmations(ctx context.Contex _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for AddTransactionConfirmations") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, bool, ...*apitypes.Confirmation) error); ok { r0 = rf(ctx, txID, clearExisting, confirmations...) @@ -46,6 +50,10 @@ func (_m *TransactionPersistence) AddTransactionConfirmations(ctx context.Contex func (_m *TransactionPersistence) DeleteTransaction(ctx context.Context, txID string) error { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for DeleteTransaction") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { r0 = rf(ctx, txID) @@ -60,6 +68,10 @@ func (_m *TransactionPersistence) DeleteTransaction(ctx context.Context, txID st func (_m *TransactionPersistence) GetTransactionByID(ctx context.Context, txID string) (*apitypes.ManagedTX, error) { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for GetTransactionByID") + } + var r0 *apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*apitypes.ManagedTX, error)); ok { @@ -86,6 +98,10 @@ func (_m *TransactionPersistence) GetTransactionByID(ctx context.Context, txID s func (_m *TransactionPersistence) GetTransactionByIDWithStatus(ctx context.Context, txID string, history bool) (*apitypes.TXWithStatus, error) { ret := _m.Called(ctx, txID, history) + if len(ret) == 0 { + panic("no return value specified for GetTransactionByIDWithStatus") + } + var r0 *apitypes.TXWithStatus var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, bool) (*apitypes.TXWithStatus, error)); ok { @@ -112,6 +128,10 @@ func (_m *TransactionPersistence) GetTransactionByIDWithStatus(ctx context.Conte func (_m *TransactionPersistence) GetTransactionByNonce(ctx context.Context, signer string, nonce *fftypes.FFBigInt) (*apitypes.ManagedTX, error) { ret := _m.Called(ctx, signer, nonce) + if len(ret) == 0 { + panic("no return value specified for GetTransactionByNonce") + } + var r0 *apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, *fftypes.FFBigInt) (*apitypes.ManagedTX, error)); ok { @@ -138,6 +158,10 @@ func (_m *TransactionPersistence) GetTransactionByNonce(ctx context.Context, sig func (_m *TransactionPersistence) GetTransactionConfirmations(ctx context.Context, txID string) ([]*apitypes.Confirmation, error) { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for GetTransactionConfirmations") + } + var r0 []*apitypes.Confirmation var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) ([]*apitypes.Confirmation, error)); ok { @@ -164,6 +188,10 @@ func (_m *TransactionPersistence) GetTransactionConfirmations(ctx context.Contex func (_m *TransactionPersistence) GetTransactionReceipt(ctx context.Context, txID string) (*ffcapi.TransactionReceiptResponse, error) { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for GetTransactionReceipt") + } + var r0 *ffcapi.TransactionReceiptResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*ffcapi.TransactionReceiptResponse, error)); ok { @@ -190,6 +218,10 @@ func (_m *TransactionPersistence) GetTransactionReceipt(ctx context.Context, txI func (_m *TransactionPersistence) InsertTransactionPreAssignedNonce(ctx context.Context, tx *apitypes.ManagedTX) error { ret := _m.Called(ctx, tx) + if len(ret) == 0 { + panic("no return value specified for InsertTransactionPreAssignedNonce") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.ManagedTX) error); ok { r0 = rf(ctx, tx) @@ -204,6 +236,10 @@ func (_m *TransactionPersistence) InsertTransactionPreAssignedNonce(ctx context. func (_m *TransactionPersistence) InsertTransactionWithNextNonce(ctx context.Context, tx *apitypes.ManagedTX, lookupNextNonce txhandler.NextNonceCallback) error { ret := _m.Called(ctx, tx, lookupNextNonce) + if len(ret) == 0 { + panic("no return value specified for InsertTransactionWithNextNonce") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.ManagedTX, txhandler.NextNonceCallback) error); ok { r0 = rf(ctx, tx, lookupNextNonce) @@ -218,6 +254,10 @@ func (_m *TransactionPersistence) InsertTransactionWithNextNonce(ctx context.Con func (_m *TransactionPersistence) ListTransactionsByCreateTime(ctx context.Context, after *apitypes.ManagedTX, limit int, dir txhandler.SortDirection) ([]*apitypes.ManagedTX, error) { ret := _m.Called(ctx, after, limit, dir) + if len(ret) == 0 { + panic("no return value specified for ListTransactionsByCreateTime") + } + var r0 []*apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, *apitypes.ManagedTX, int, txhandler.SortDirection) ([]*apitypes.ManagedTX, error)); ok { @@ -244,6 +284,10 @@ func (_m *TransactionPersistence) ListTransactionsByCreateTime(ctx context.Conte func (_m *TransactionPersistence) ListTransactionsByNonce(ctx context.Context, signer string, after *fftypes.FFBigInt, limit int, dir txhandler.SortDirection) ([]*apitypes.ManagedTX, error) { ret := _m.Called(ctx, signer, after, limit, dir) + if len(ret) == 0 { + panic("no return value specified for ListTransactionsByNonce") + } + var r0 []*apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, *fftypes.FFBigInt, int, txhandler.SortDirection) ([]*apitypes.ManagedTX, error)); ok { @@ -270,6 +314,10 @@ func (_m *TransactionPersistence) ListTransactionsByNonce(ctx context.Context, s func (_m *TransactionPersistence) ListTransactionsPending(ctx context.Context, afterSequenceID string, limit int, dir txhandler.SortDirection) ([]*apitypes.ManagedTX, error) { ret := _m.Called(ctx, afterSequenceID, limit, dir) + if len(ret) == 0 { + panic("no return value specified for ListTransactionsPending") + } + var r0 []*apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, int, txhandler.SortDirection) ([]*apitypes.ManagedTX, error)); ok { @@ -296,6 +344,10 @@ func (_m *TransactionPersistence) ListTransactionsPending(ctx context.Context, a func (_m *TransactionPersistence) SetTransactionReceipt(ctx context.Context, txID string, receipt *ffcapi.TransactionReceiptResponse) error { ret := _m.Called(ctx, txID, receipt) + if len(ret) == 0 { + panic("no return value specified for SetTransactionReceipt") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, *ffcapi.TransactionReceiptResponse) error); ok { r0 = rf(ctx, txID, receipt) @@ -310,6 +362,10 @@ func (_m *TransactionPersistence) SetTransactionReceipt(ctx context.Context, txI func (_m *TransactionPersistence) UpdateTransaction(ctx context.Context, txID string, updates *apitypes.TXUpdates) error { ret := _m.Called(ctx, txID, updates) + if len(ret) == 0 { + panic("no return value specified for UpdateTransaction") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, *apitypes.TXUpdates) error); ok { r0 = rf(ctx, txID, updates) diff --git a/mocks/txhandlermocks/managed_tx_event_handler.go b/mocks/txhandlermocks/managed_tx_event_handler.go index 30cc57c4..a041c8f2 100644 --- a/mocks/txhandlermocks/managed_tx_event_handler.go +++ b/mocks/txhandlermocks/managed_tx_event_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package txhandlermocks @@ -19,6 +19,10 @@ type ManagedTxEventHandler struct { func (_m *ManagedTxEventHandler) HandleEvent(ctx context.Context, e apitypes.ManagedTransactionEvent) error { ret := _m.Called(ctx, e) + if len(ret) == 0 { + panic("no return value specified for HandleEvent") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, apitypes.ManagedTransactionEvent) error); ok { r0 = rf(ctx, e) diff --git a/mocks/txhandlermocks/transaction_handler.go b/mocks/txhandlermocks/transaction_handler.go index 6590823a..0fe285fd 100644 --- a/mocks/txhandlermocks/transaction_handler.go +++ b/mocks/txhandlermocks/transaction_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package txhandlermocks @@ -23,6 +23,10 @@ type TransactionHandler struct { func (_m *TransactionHandler) HandleCancelTransaction(ctx context.Context, txID string) (*apitypes.ManagedTX, error) { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for HandleCancelTransaction") + } + var r0 *apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*apitypes.ManagedTX, error)); ok { @@ -46,12 +50,17 @@ func (_m *TransactionHandler) HandleCancelTransaction(ctx context.Context, txID } // HandleNewContractDeployment provides a mock function with given fields: ctx, txReq -func (_m *TransactionHandler) HandleNewContractDeployment(ctx context.Context, txReq *apitypes.ContractDeployRequest) (*apitypes.ManagedTX, error) { +func (_m *TransactionHandler) HandleNewContractDeployment(ctx context.Context, txReq *apitypes.ContractDeployRequest) (*apitypes.ManagedTX, bool, error) { ret := _m.Called(ctx, txReq) + if len(ret) == 0 { + panic("no return value specified for HandleNewContractDeployment") + } + var r0 *apitypes.ManagedTX - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *apitypes.ContractDeployRequest) (*apitypes.ManagedTX, error)); ok { + var r1 bool + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *apitypes.ContractDeployRequest) (*apitypes.ManagedTX, bool, error)); ok { return rf(ctx, txReq) } if rf, ok := ret.Get(0).(func(context.Context, *apitypes.ContractDeployRequest) *apitypes.ManagedTX); ok { @@ -62,22 +71,33 @@ func (_m *TransactionHandler) HandleNewContractDeployment(ctx context.Context, t } } - if rf, ok := ret.Get(1).(func(context.Context, *apitypes.ContractDeployRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *apitypes.ContractDeployRequest) bool); ok { r1 = rf(ctx, txReq) } else { - r1 = ret.Error(1) + r1 = ret.Get(1).(bool) } - return r0, r1 + if rf, ok := ret.Get(2).(func(context.Context, *apitypes.ContractDeployRequest) error); ok { + r2 = rf(ctx, txReq) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 } // HandleNewTransaction provides a mock function with given fields: ctx, txReq -func (_m *TransactionHandler) HandleNewTransaction(ctx context.Context, txReq *apitypes.TransactionRequest) (*apitypes.ManagedTX, error) { +func (_m *TransactionHandler) HandleNewTransaction(ctx context.Context, txReq *apitypes.TransactionRequest) (*apitypes.ManagedTX, bool, error) { ret := _m.Called(ctx, txReq) + if len(ret) == 0 { + panic("no return value specified for HandleNewTransaction") + } + var r0 *apitypes.ManagedTX - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *apitypes.TransactionRequest) (*apitypes.ManagedTX, error)); ok { + var r1 bool + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *apitypes.TransactionRequest) (*apitypes.ManagedTX, bool, error)); ok { return rf(ctx, txReq) } if rf, ok := ret.Get(0).(func(context.Context, *apitypes.TransactionRequest) *apitypes.ManagedTX); ok { @@ -88,19 +108,29 @@ func (_m *TransactionHandler) HandleNewTransaction(ctx context.Context, txReq *a } } - if rf, ok := ret.Get(1).(func(context.Context, *apitypes.TransactionRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *apitypes.TransactionRequest) bool); ok { r1 = rf(ctx, txReq) } else { - r1 = ret.Error(1) + r1 = ret.Get(1).(bool) } - return r0, r1 + if rf, ok := ret.Get(2).(func(context.Context, *apitypes.TransactionRequest) error); ok { + r2 = rf(ctx, txReq) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 } // HandleResumeTransaction provides a mock function with given fields: ctx, txID func (_m *TransactionHandler) HandleResumeTransaction(ctx context.Context, txID string) (*apitypes.ManagedTX, error) { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for HandleResumeTransaction") + } + var r0 *apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*apitypes.ManagedTX, error)); ok { @@ -127,6 +157,10 @@ func (_m *TransactionHandler) HandleResumeTransaction(ctx context.Context, txID func (_m *TransactionHandler) HandleSuspendTransaction(ctx context.Context, txID string) (*apitypes.ManagedTX, error) { ret := _m.Called(ctx, txID) + if len(ret) == 0 { + panic("no return value specified for HandleSuspendTransaction") + } + var r0 *apitypes.ManagedTX var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*apitypes.ManagedTX, error)); ok { @@ -153,6 +187,10 @@ func (_m *TransactionHandler) HandleSuspendTransaction(ctx context.Context, txID func (_m *TransactionHandler) HandleTransactionConfirmations(ctx context.Context, txID string, notification *apitypes.ConfirmationsNotification) error { ret := _m.Called(ctx, txID, notification) + if len(ret) == 0 { + panic("no return value specified for HandleTransactionConfirmations") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, *apitypes.ConfirmationsNotification) error); ok { r0 = rf(ctx, txID, notification) @@ -167,6 +205,10 @@ func (_m *TransactionHandler) HandleTransactionConfirmations(ctx context.Context func (_m *TransactionHandler) HandleTransactionReceiptReceived(ctx context.Context, txID string, receipt *ffcapi.TransactionReceiptResponse) error { ret := _m.Called(ctx, txID, receipt) + if len(ret) == 0 { + panic("no return value specified for HandleTransactionReceiptReceived") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, *ffcapi.TransactionReceiptResponse) error); ok { r0 = rf(ctx, txID, receipt) @@ -186,6 +228,10 @@ func (_m *TransactionHandler) Init(ctx context.Context, toolkit *txhandler.Toolk func (_m *TransactionHandler) Start(ctx context.Context) (<-chan struct{}, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 <-chan struct{} var r1 error if rf, ok := ret.Get(0).(func(context.Context) (<-chan struct{}, error)); ok { diff --git a/mocks/wsmocks/web_socket_channels.go b/mocks/wsmocks/web_socket_channels.go index deacf936..36ed8f9b 100644 --- a/mocks/wsmocks/web_socket_channels.go +++ b/mocks/wsmocks/web_socket_channels.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package wsmocks @@ -16,6 +16,10 @@ type WebSocketChannels struct { func (_m *WebSocketChannels) GetChannels(topic string) (chan<- interface{}, chan<- interface{}, <-chan *ws.WebSocketCommandMessageOrError) { ret := _m.Called(topic) + if len(ret) == 0 { + panic("no return value specified for GetChannels") + } + var r0 chan<- interface{} var r1 chan<- interface{} var r2 <-chan *ws.WebSocketCommandMessageOrError diff --git a/mocks/wsmocks/web_socket_server.go b/mocks/wsmocks/web_socket_server.go index c1555c76..36866545 100644 --- a/mocks/wsmocks/web_socket_server.go +++ b/mocks/wsmocks/web_socket_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.32.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package wsmocks @@ -23,6 +23,10 @@ func (_m *WebSocketServer) Close() { func (_m *WebSocketServer) GetChannels(topic string) (chan<- interface{}, chan<- interface{}, <-chan *ws.WebSocketCommandMessageOrError) { ret := _m.Called(topic) + if len(ret) == 0 { + panic("no return value specified for GetChannels") + } + var r0 chan<- interface{} var r1 chan<- interface{} var r2 <-chan *ws.WebSocketCommandMessageOrError diff --git a/pkg/ffcapi/api.go b/pkg/ffcapi/api.go index e5cfef15..01255155 100644 --- a/pkg/ffcapi/api.go +++ b/pkg/ffcapi/api.go @@ -173,6 +173,7 @@ type ListenerEvent struct { // It is important that error mapping is performed for each of these classification type ErrorReason string +// *** MUST UPDATE MapSubmissionRejected IF ADDING NEW REASONS THAT ARE POSSIBLE DURING TRANSACTION PREPARE PHASE OF SUBMISSION *** const ( // ErrorReasonInvalidInputs transaction inputs could not be parsed by the connector according to the interface (nothing was sent to the blockchain) ErrorReasonInvalidInputs ErrorReason = "invalid_inputs" diff --git a/pkg/ffcapi/submission_error.go b/pkg/ffcapi/submission_error.go new file mode 100644 index 00000000..3214ce52 --- /dev/null +++ b/pkg/ffcapi/submission_error.go @@ -0,0 +1,40 @@ +// Copyright © 2023 Kaleido, Inc. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ffcapi + +type SubmissionError struct { + Error string `json:"error"` + // When submissionRejected: true, the failure is considered final and the operation should transition directly to failed. + // This should be returned in all cases where the FFCAPI connector or underlying blockchain node has evaluated the transaction + // during the prepare phase, and determined it will fail if it were submitted. + // The idempotencyKey is "spent" in these scenarios in the FF Core layer, but the transaction is never recorded into the FFTM + // database, so the nonce is not spent, and the transaction is never submitted. + SubmissionRejected bool `json:"submissionRejected,omitempty"` +} + +func MapSubmissionRejected(reason ErrorReason) bool { + switch reason { + case ErrorReasonInvalidInputs, + ErrorReasonTransactionReverted, + ErrorReasonInsufficientFunds: + // These reason codes are considered as rejections of the transaction - see ffcapi.SubmissionError + return true + default: + // Everything else is eligible for idempotent retry of submission + return false + } +} diff --git a/pkg/ffcapi/submission_error_test.go b/pkg/ffcapi/submission_error_test.go new file mode 100644 index 00000000..01086bfc --- /dev/null +++ b/pkg/ffcapi/submission_error_test.go @@ -0,0 +1,31 @@ +// Copyright © 2023 Kaleido, Inc. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ffcapi + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMapSubmissionError(t *testing.T) { + assert.True(t, MapSubmissionRejected(ErrorReasonTransactionReverted)) + assert.True(t, MapSubmissionRejected(ErrorReasonInvalidInputs)) + assert.True(t, MapSubmissionRejected(ErrorReasonInsufficientFunds)) + assert.False(t, MapSubmissionRejected(ErrorReasonTransactionUnderpriced)) + assert.False(t, MapSubmissionRejected("")) +} diff --git a/pkg/fftm/api.go b/pkg/fftm/api.go index bfcf246b..c686d459 100644 --- a/pkg/fftm/api.go +++ b/pkg/fftm/api.go @@ -17,10 +17,8 @@ package fftm import ( - "encoding/json" "net/http" - "github.com/ghodss/yaml" "github.com/gorilla/mux" "github.com/hyperledger/firefly-common/pkg/config" "github.com/hyperledger/firefly-common/pkg/ffapi" @@ -41,41 +39,23 @@ func (m *manager) router(metricsEnabled bool) *mux.Router { MaxTimeout: config.GetDuration(tmconfig.APIMaxRequestTimeout), PassthroughHeaders: config.GetStringSlice(tmconfig.APIPassthroughHeaders), } + oah := &ffapi.OpenAPIHandlerFactory{ + BaseSwaggerGenOptions: ffapi.SwaggerGenOptions{ + Title: "FireFly Transaction Manager API", + Version: "1.0", + PanicOnMissingDescription: testDescriptions, + DefaultRequestTimeout: config.GetDuration(tmconfig.APIDefaultRequestTimeout), + SupportFieldRedaction: true, + }, + } + routes := m.routes() for _, r := range routes { mux.Path(r.Path).Methods(r.Method).Handler(hf.RouteHandler(r)) } - mux.Path("/api").Methods(http.MethodGet).Handler(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - url := req.URL.String() + "/spec.yaml" - handler := hf.APIWrapper(hf.SwaggerUIHandler(url)) - handler(res, req) - })) - mux.Path("/api/spec.yaml").Methods(http.MethodGet).Handler(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - u := req.URL - u.Path = "" - swaggerGen := ffapi.NewSwaggerGen(&ffapi.Options{ - BaseURL: u.String(), - PanicOnMissingDescription: testDescriptions, - DefaultRequestTimeout: config.GetDuration(tmconfig.APIDefaultRequestTimeout), - }) - doc := swaggerGen.Generate(req.Context(), routes) - res.Header().Add("Content-Type", "application/x-yaml") - b, _ := yaml.Marshal(&doc) - _, _ = res.Write(b) - })) - mux.Path("/api/spec.json").Methods(http.MethodGet).Handler(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - u := req.URL - u.Path = "" - swaggerGen := ffapi.NewSwaggerGen(&ffapi.Options{ - BaseURL: u.String(), - PanicOnMissingDescription: testDescriptions, - DefaultRequestTimeout: config.GetDuration(tmconfig.APIDefaultRequestTimeout), - }) - doc := swaggerGen.Generate(req.Context(), routes) - res.Header().Add("Content-Type", "application/json") - b, _ := json.Marshal(&doc) - _, _ = res.Write(b) - })) + mux.Path("/api").Methods(http.MethodGet).Handler(hf.APIWrapper(oah.SwaggerUIHandler(""))) + mux.Path("/api/spec.yaml").Methods(http.MethodGet).Handler(hf.APIWrapper(oah.OpenAPIHandler("", ffapi.OpenAPIFormatYAML, routes))) + mux.Path("/api/spec.json").Methods(http.MethodGet).Handler(hf.APIWrapper(oah.OpenAPIHandler("", ffapi.OpenAPIFormatJSON, routes))) mux.HandleFunc("/ws", m.wsServer.Handler) diff --git a/pkg/fftm/api_test.go b/pkg/fftm/api_test.go index cd36cc10..ce374845 100644 --- a/pkg/fftm/api_test.go +++ b/pkg/fftm/api_test.go @@ -23,7 +23,9 @@ import ( "github.com/go-resty/resty/v2" "github.com/hyperledger/firefly-common/pkg/fftypes" + "github.com/hyperledger/firefly-common/pkg/i18n" "github.com/hyperledger/firefly-transaction-manager/internal/confirmations" + "github.com/hyperledger/firefly-transaction-manager/internal/tmmsgs" "github.com/hyperledger/firefly-transaction-manager/mocks/confirmationsmocks" "github.com/hyperledger/firefly-transaction-manager/mocks/ffcapimocks" "github.com/hyperledger/firefly-transaction-manager/pkg/apitypes" @@ -162,13 +164,14 @@ func TestSendInvalidRequestBadTXType(t *testing.T) { "Not": "a string" } }`) - var errRes fftypes.RESTError + var errRes ffcapi.SubmissionError res, err := resty.New().R(). SetBody(req). SetError(&errRes). Post(url) assert.NoError(t, err) assert.Equal(t, 400, res.StatusCode()) + assert.True(t, errRes.SubmissionRejected) assert.Regexp(t, "FF21022", errRes.Error) } @@ -186,13 +189,14 @@ func TestSendInvalidDeployBadTXType(t *testing.T) { "Not": "a string" } }`) - var errRes fftypes.RESTError + var errRes ffcapi.SubmissionError res, err := resty.New().R(). SetBody(req). SetError(&errRes). Post(url) assert.NoError(t, err) assert.Equal(t, 400, res.StatusCode()) + assert.True(t, errRes.SubmissionRejected) assert.Regexp(t, "FF21022", errRes.Error) } @@ -256,16 +260,21 @@ func TestSendTransactionPrepareFail(t *testing.T) { Nonce: fftypes.NewFFBigInt(12345), }, ffcapi.ErrorReason(""), nil) - mFFC.On("TransactionPrepare", mock.Anything, mock.Anything).Return(nil, ffcapi.ErrorReason(""), fmt.Errorf("pop")) + mFFC.On("TransactionPrepare", mock.Anything, mock.Anything). + // Reverted reason will give us a submission error + Return(nil, ffcapi.ErrorReasonTransactionReverted, i18n.NewError(m.ctx, tmmsgs.MsgTransactionFailed)) m.Start() req := strings.NewReader(sampleSendTX) + var errRes ffcapi.SubmissionError res, err := resty.New().R(). SetBody(req). + SetError(&errRes). Post(url) assert.NoError(t, err) assert.Equal(t, 500, res.StatusCode()) + assert.True(t, errRes.SubmissionRejected) } diff --git a/pkg/fftm/manager_test.go b/pkg/fftm/manager_test.go index d0543d8d..18942560 100644 --- a/pkg/fftm/manager_test.go +++ b/pkg/fftm/manager_test.go @@ -37,6 +37,7 @@ import ( "github.com/hyperledger/firefly-transaction-manager/pkg/txhandler" txRegistry "github.com/hyperledger/firefly-transaction-manager/pkg/txhandler/registry" "github.com/hyperledger/firefly-transaction-manager/pkg/txhandler/simple" + "github.com/sirupsen/logrus" "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -76,10 +77,11 @@ func testManagerCommonInit(t *testing.T, withMetrics bool) string { } func newTestManager(t *testing.T) (string, *manager, func()) { + logrus.SetLevel(logrus.TraceLevel) url := testManagerCommonInit(t, false) - dir, err := ioutil.TempDir("", "ldb_*") + dir, err := os.MkdirTemp("", "ldb_*") assert.NoError(t, err) config.Set(tmconfig.PersistenceLevelDBPath, dir) @@ -165,7 +167,7 @@ func newTestManagerWithMetrics(t *testing.T) (string, *manager, func()) { url := testManagerCommonInit(t, true) - dir, err := ioutil.TempDir("", "ldb_*") + dir, err := os.MkdirTemp("", "ldb_*") assert.NoError(t, err) config.Set(tmconfig.PersistenceLevelDBPath, dir) @@ -249,7 +251,7 @@ func TestNewManagerBadHttpConfig(t *testing.T) { tmconfig.Reset() tmconfig.APIConfig.Set(httpserver.HTTPConfAddress, "::::") - dir, err := ioutil.TempDir("", "ldb_*") + dir, err := os.MkdirTemp("", "ldb_*") defer os.RemoveAll(dir) assert.NoError(t, err) config.Set(tmconfig.PersistenceLevelDBPath, dir) @@ -298,7 +300,7 @@ func TestNewManagerBadPersistenceConfig(t *testing.T) { func TestNewManagerInvalidTransactionHandlerName(t *testing.T) { tmconfig.Reset() - dir, err := ioutil.TempDir("", "ldb_*") + dir, err := os.MkdirTemp("", "ldb_*") defer os.RemoveAll(dir) assert.NoError(t, err) config.Set(tmconfig.PersistenceLevelDBPath, dir) @@ -333,7 +335,7 @@ func TestNewManagerWithMetricsBadConfig(t *testing.T) { tmconfig.MetricsConfig.Set("enabled", true) tmconfig.MetricsConfig.Set(httpserver.HTTPConfAddress, "::::") - dir, err := ioutil.TempDir("", "ldb_*") + dir, err := os.MkdirTemp("", "ldb_*") defer os.RemoveAll(dir) assert.NoError(t, err) config.Set(tmconfig.PersistenceLevelDBPath, dir) diff --git a/pkg/fftm/route__root_command.go b/pkg/fftm/route__root_command.go index ea44160a..cb8407aa 100644 --- a/pkg/fftm/route__root_command.go +++ b/pkg/fftm/route__root_command.go @@ -23,9 +23,11 @@ import ( "github.com/getkin/kin-openapi/openapi3" "github.com/hyperledger/firefly-common/pkg/ffapi" "github.com/hyperledger/firefly-common/pkg/i18n" + "github.com/hyperledger/firefly-common/pkg/log" "github.com/hyperledger/firefly-transaction-manager/internal/tmmsgs" "github.com/hyperledger/firefly-transaction-manager/pkg/apitypes" "github.com/hyperledger/firefly-transaction-manager/pkg/ffcapi" + "github.com/sirupsen/logrus" ) var postRootCommand = func(m *manager) *ffapi.Route { @@ -75,17 +77,23 @@ var postRootCommand = func(m *manager) *ffapi.Route { baseReq := r.Input.(*apitypes.BaseRequest) switch baseReq.Headers.Type { case apitypes.RequestTypeSendTransaction: - var tReq apitypes.TransactionRequest - if err = baseReq.UnmarshalTo(&tReq); err != nil { - return nil, i18n.NewError(r.Req.Context(), tmmsgs.MsgInvalidRequestErr, baseReq.Headers.Type, err) - } - return m.txHandler.HandleNewTransaction(r.Req.Context(), &tReq) + // We have to supply an extra submissionRejected boolean on submission errors + return mapSubmissionErrors(r, func() (output interface{}, submissionRejected bool, err error) { + var tReq apitypes.TransactionRequest + if err = baseReq.UnmarshalTo(&tReq); err != nil { + return nil, true /* reject */, i18n.NewError(r.Req.Context(), tmmsgs.MsgInvalidRequestErr, baseReq.Headers.Type, err) + } + return m.txHandler.HandleNewTransaction(r.Req.Context(), &tReq) + }), nil case apitypes.RequestTypeDeploy: - var tReq apitypes.ContractDeployRequest - if err = baseReq.UnmarshalTo(&tReq); err != nil { - return nil, i18n.NewError(r.Req.Context(), tmmsgs.MsgInvalidRequestErr, baseReq.Headers.Type, err) - } - return m.txHandler.HandleNewContractDeployment(r.Req.Context(), &tReq) + // We have to supply an extra submissionRejected boolean on submission errors + return mapSubmissionErrors(r, func() (output interface{}, submissionRejected bool, err error) { + var tReq apitypes.ContractDeployRequest + if err = baseReq.UnmarshalTo(&tReq); err != nil { + return nil, true /* reject */, i18n.NewError(r.Req.Context(), tmmsgs.MsgInvalidRequestErr, baseReq.Headers.Type, err) + } + return m.txHandler.HandleNewContractDeployment(r.Req.Context(), &tReq) + }), nil case apitypes.RequestTypeQuery: var tReq apitypes.QueryRequest if err = baseReq.UnmarshalTo(&tReq); err != nil { @@ -104,3 +112,25 @@ var postRootCommand = func(m *manager) *ffapi.Route { }, } } + +// Common function to help us supply an extra submissionRejected boolean on submission errors. +func mapSubmissionErrors(r *ffapi.APIRequest, handler func() (output interface{}, submissionRejected bool, err error)) interface{} { + output, submissionRejected, err := handler() + if err == nil { + return output + } + l := log.L(r.Req.Context()) + status := 500 + if ffe, ok := (interface{}(err)).(i18n.FFError); ok { + if logrus.IsLevelEnabled(logrus.DebugLevel) { + l.Debugf("%s:\n%s", ffe.Error(), ffe.StackTrace()) + } + status = ffe.HTTPStatus() + } + r.SuccessStatus = status + l.Errorf("Submission failed (submissionRejected=%t) [%d]: %s", submissionRejected, status, err) + return &ffcapi.SubmissionError{ + Error: err.Error(), + SubmissionRejected: submissionRejected, + } +} diff --git a/pkg/txhandler/simple/policyloop_test.go b/pkg/txhandler/simple/policyloop_test.go index c845af9c..92f76dab 100644 --- a/pkg/txhandler/simple/policyloop_test.go +++ b/pkg/txhandler/simple/policyloop_test.go @@ -61,7 +61,7 @@ func sendSampleTX(t *testing.T, sth *simpleTransactionHandler, signer string, no TransactionData: "0xabce1234", }, ffcapi.ErrorReason(""), nil).Once() - mtx, err := sth.HandleNewTransaction(ctx, &apitypes.TransactionRequest{ + mtx, _, err := sth.HandleNewTransaction(ctx, &apitypes.TransactionRequest{ Headers: apitypes.RequestHeaders{ ID: txID, }, @@ -91,10 +91,11 @@ func sendSampleDeployment(t *testing.T, sth *simpleTransactionHandler, signer st TransactionData: "0xabce1234", }, ffcapi.ErrorReason(""), nil).Once() - mtx, err := sth.HandleNewContractDeployment(ctx, &apitypes.ContractDeployRequest{ + mtx, submissionRejected, err := sth.HandleNewContractDeployment(ctx, &apitypes.ContractDeployRequest{ ContractDeployPrepareRequest: contractDeployPrepareRequest, }) assert.NoError(t, err) + assert.False(t, submissionRejected) return mtx } @@ -247,13 +248,14 @@ func TestTransactionPreparationErrors(t *testing.T) { ctx := context.Background() mfc.On("TransactionPrepare", ctx, &ffcapi.TransactionPrepareRequest{ TransactionInput: txInput, - }).Return(nil, ffcapi.ErrorReason(""), fmt.Errorf("txPop")).Once() + }).Return(nil, ffcapi.ErrorReasonTransactionReverted, fmt.Errorf("reverted")).Once() mfc.On("DeployContractPrepare", ctx, mock.Anything).Return(nil, ffcapi.ErrorReason(""), fmt.Errorf("contractPop")).Once() - _, err = sth.HandleNewTransaction(ctx, &apitypes.TransactionRequest{ + _, submissionRejected, err := sth.HandleNewTransaction(ctx, &apitypes.TransactionRequest{ TransactionInput: txInput, }) - assert.Equal(t, "txPop", err.Error()) + assert.True(t, submissionRejected) + assert.Equal(t, "reverted", err.Error()) contractDeployPrepareRequest := ffcapi.ContractDeployPrepareRequest{ TransactionHeaders: ffcapi.TransactionHeaders{ @@ -261,7 +263,7 @@ func TestTransactionPreparationErrors(t *testing.T) { }, Contract: fftypes.JSONAnyPtrBytes([]byte("0xfeedbeef")), } - _, err = sth.HandleNewContractDeployment(ctx, &apitypes.ContractDeployRequest{ + _, _, err = sth.HandleNewContractDeployment(ctx, &apitypes.ContractDeployRequest{ ContractDeployPrepareRequest: contractDeployPrepareRequest, }) assert.Equal(t, "contractPop", err.Error()) diff --git a/pkg/txhandler/simple/simple_transaction_hander_test.go b/pkg/txhandler/simple/simple_transaction_hander_test.go index 576823ed..34a139aa 100644 --- a/pkg/txhandler/simple/simple_transaction_hander_test.go +++ b/pkg/txhandler/simple/simple_transaction_hander_test.go @@ -20,7 +20,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "math/big" "net/http" "net/http/httptest" @@ -91,7 +90,7 @@ func newTestTransactionHandlerFactoryWithFilePersistence(t *testing.T) (*Transac conf.SubSection(GasOracleConfig).Set(GasOracleMode, GasOracleModeDisabled) assert.Equal(t, "simple", f.Name()) - dir, err := ioutil.TempDir("", "ldb_*") + dir, err := os.MkdirTemp("", "ldb_*") assert.NoError(t, err) config.Set(tmconfig.PersistenceLevelDBPath, dir) filePersistence, err := leveldb.NewLevelDBPersistence(context.Background(), 1*time.Hour) @@ -901,7 +900,7 @@ func TestIdempotencyIDPreCheckError(t *testing.T) { mp := tk.TXPersistence.(*persistencemocks.Persistence) mp.On("GetTransactionByID", mock.Anything, "reused").Return(nil, fmt.Errorf("pop")) - _, err = sth.HandleNewTransaction(sth.ctx, &apitypes.TransactionRequest{ + _, _, err = sth.HandleNewTransaction(sth.ctx, &apitypes.TransactionRequest{ Headers: apitypes.RequestHeaders{ ID: "reused", }, @@ -931,7 +930,7 @@ func TestIdempotencyIDPreCheckDuplicate(t *testing.T) { mp := tk.TXPersistence.(*persistencemocks.Persistence) mp.On("GetTransactionByID", mock.Anything, "reused").Return(existingTX, nil) - _, err = sth.HandleNewTransaction(sth.ctx, &apitypes.TransactionRequest{ + _, _, err = sth.HandleNewTransaction(sth.ctx, &apitypes.TransactionRequest{ Headers: apitypes.RequestHeaders{ ID: "reused", }, @@ -961,7 +960,7 @@ func TestIdempotencyIDPreCheckDuplicateDeploy(t *testing.T) { mp := tk.TXPersistence.(*persistencemocks.Persistence) mp.On("GetTransactionByID", mock.Anything, "reused").Return(existingTX, nil) - _, err = sth.HandleNewContractDeployment(sth.ctx, &apitypes.ContractDeployRequest{ + _, _, err = sth.HandleNewContractDeployment(sth.ctx, &apitypes.ContractDeployRequest{ Headers: apitypes.RequestHeaders{ ID: "reused", }, diff --git a/pkg/txhandler/simple/simple_transaction_handler.go b/pkg/txhandler/simple/simple_transaction_handler.go index 6aef804e..091fa0ac 100644 --- a/pkg/txhandler/simple/simple_transaction_handler.go +++ b/pkg/txhandler/simple/simple_transaction_handler.go @@ -241,40 +241,42 @@ func (sth *simpleTransactionHandler) requestIDPreCheck(ctx context.Context, reqH return txID, nil } -func (sth *simpleTransactionHandler) HandleNewTransaction(ctx context.Context, txReq *apitypes.TransactionRequest) (mtx *apitypes.ManagedTX, err error) { +func (sth *simpleTransactionHandler) HandleNewTransaction(ctx context.Context, txReq *apitypes.TransactionRequest) (mtx *apitypes.ManagedTX, submissionRejected bool, err error) { txID, err := sth.requestIDPreCheck(ctx, &txReq.Headers) if err != nil { - return nil, err + return nil, false, err } // Prepare the transaction, which will mean we have a transaction that should be submittable. // If we fail at this stage, we don't need to write any state as we are sure we haven't submitted // anything to the blockchain itself. - prepared, _, err := sth.toolkit.Connector.TransactionPrepare(ctx, &ffcapi.TransactionPrepareRequest{ + prepared, reason, err := sth.toolkit.Connector.TransactionPrepare(ctx, &ffcapi.TransactionPrepareRequest{ TransactionInput: txReq.TransactionInput, }) if err != nil { - return nil, err + return nil, ffcapi.MapSubmissionRejected(reason), err } - return sth.createManagedTx(ctx, txID, &txReq.TransactionHeaders, prepared.Gas, prepared.TransactionData) + mtx, err = sth.createManagedTx(ctx, txID, &txReq.TransactionHeaders, prepared.Gas, prepared.TransactionData) + return mtx, false, err } -func (sth *simpleTransactionHandler) HandleNewContractDeployment(ctx context.Context, txReq *apitypes.ContractDeployRequest) (mtx *apitypes.ManagedTX, err error) { +func (sth *simpleTransactionHandler) HandleNewContractDeployment(ctx context.Context, txReq *apitypes.ContractDeployRequest) (mtx *apitypes.ManagedTX, submissionRejected bool, err error) { txID, err := sth.requestIDPreCheck(ctx, &txReq.Headers) if err != nil { - return nil, err + return nil, false, err } // Prepare the transaction, which will mean we have a transaction that should be submittable. // If we fail at this stage, we don't need to write any state as we are sure we haven't submitted // anything to the blockchain itself. - prepared, _, err := sth.toolkit.Connector.DeployContractPrepare(ctx, &txReq.ContractDeployPrepareRequest) + prepared, reason, err := sth.toolkit.Connector.DeployContractPrepare(ctx, &txReq.ContractDeployPrepareRequest) if err != nil { - return nil, err + return nil, ffcapi.MapSubmissionRejected(reason), err } - return sth.createManagedTx(ctx, txID, &txReq.TransactionHeaders, prepared.Gas, prepared.TransactionData) + mtx, err = sth.createManagedTx(ctx, txID, &txReq.TransactionHeaders, prepared.Gas, prepared.TransactionData) + return mtx, false, err } func (sth *simpleTransactionHandler) HandleCancelTransaction(ctx context.Context, txID string) (mtx *apitypes.ManagedTX, err error) { diff --git a/pkg/txhandler/txhandler.go b/pkg/txhandler/txhandler.go index 9c2dd068..6ff70c21 100644 --- a/pkg/txhandler/txhandler.go +++ b/pkg/txhandler/txhandler.go @@ -156,9 +156,9 @@ type TransactionHandler interface { // Event handling functions // Instructional events: // HandleNewTransaction - handles event of adding new transactions onto blockchain - HandleNewTransaction(ctx context.Context, txReq *apitypes.TransactionRequest) (mtx *apitypes.ManagedTX, err error) + HandleNewTransaction(ctx context.Context, txReq *apitypes.TransactionRequest) (mtx *apitypes.ManagedTX, submissionRejected bool, err error) // HandleNewContractDeployment - handles event of adding new smart contract deployment onto blockchain - HandleNewContractDeployment(ctx context.Context, txReq *apitypes.ContractDeployRequest) (mtx *apitypes.ManagedTX, err error) + HandleNewContractDeployment(ctx context.Context, txReq *apitypes.ContractDeployRequest) (mtx *apitypes.ManagedTX, submissionRejected bool, err error) // HandleCancelTransaction - handles event of cancelling a managed transaction HandleCancelTransaction(ctx context.Context, txID string) (mtx *apitypes.ManagedTX, err error) // HandleSuspendTransaction - handles event of suspending a managed transaction