diff --git a/Gopkg.lock b/Gopkg.lock index c4575b8eb..ae6710a21 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -3,17 +3,22 @@ [[projects]] branch = "master" + digest = "1:6a4c3eb799262645ef273acaf96bf25545682b05a4830759fa91ddf6e6bbe05a" name = "github.com/anthdm/rfc6979" packages = ["."] + pruneopts = "UT" revision = "6a90f24967ebb1aa57b22f74a13dbb3faad8cf3d" [[projects]] + digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39" name = "github.com/davecgh/go-spew" packages = ["spew"] + pruneopts = "UT" revision = "346938d642f2ec3594ed81d874461961cd0faa76" version = "v1.1.0" [[projects]] + digest = "1:6361fc2f37f6a779924d408a955883db8ae02255a26473517b03cd0a80f8cdd5" name = "github.com/go-redis/redis" packages = [ ".", @@ -23,49 +28,66 @@ "internal/pool", "internal/proto", "internal/singleflight", - "internal/util" + "internal/util", ] + pruneopts = "UT" revision = "877867d2845fbaf86798befe410b6ceb6f5c29a3" version = "v6.10.2" [[projects]] + digest = "1:2a81c6e126d36ad027328cffaa4888fc3be40f09dc48028d1f93705b718130b9" name = "github.com/go-yaml/yaml" packages = ["."] + pruneopts = "UT" revision = "7f97868eec74b32b0982dd158a51a446d1da7eb5" version = "v2.1.1" [[projects]] branch = "master" + digest = "1:29a5ab9fa9e845fd8e8726f31b187d710afd271ef1eb32085fe3d604b7e06382" name = "github.com/golang/snappy" packages = ["."] + pruneopts = "UT" revision = "553a641470496b2327abcac10b36396bd98e45c9" [[projects]] + digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747" name = "github.com/pkg/errors" packages = ["."] + pruneopts = "UT" revision = "645ef00459ed84a119197bfb8d8205042c6df63d" version = "v0.8.0" [[projects]] + digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" name = "github.com/pmezard/go-difflib" packages = ["difflib"] + pruneopts = "UT" revision = "792786c7400a136282c1664665ae0a8db921c6c2" version = "v1.0.0" [[projects]] + digest = "1:9e9193aa51197513b3abcb108970d831fbcf40ef96aa845c4f03276e1fa316d2" name = "github.com/sirupsen/logrus" packages = ["."] + pruneopts = "UT" revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc" version = "v1.0.5" [[projects]] + digest = "1:7e8d267900c7fa7f35129a2a37596e38ed0f11ca746d6d9ba727980ee138f9f6" name = "github.com/stretchr/testify" - packages = ["assert"] + packages = [ + "assert", + "require", + ] + pruneopts = "UT" revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71" version = "v1.2.1" [[projects]] branch = "master" + digest = "1:54c5cf40673a32664cda38495c4aad9fca860c53b75dfe0e94d029751920ccec" name = "github.com/syndtr/goleveldb" packages = [ "leveldb", @@ -79,37 +101,45 @@ "leveldb/opt", "leveldb/storage", "leveldb/table", - "leveldb/util" + "leveldb/util", ] + pruneopts = "UT" revision = "169b1b37be738edb2813dab48c97a549bcf99bb5" [[projects]] + digest = "1:b24d38b282bacf9791408a080f606370efa3d364e4b5fd9ba0f7b87786d3b679" name = "github.com/urfave/cli" packages = ["."] + pruneopts = "UT" revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1" version = "v1.20.0" [[projects]] branch = "master" + digest = "1:4ace8274b4272d3537cd1ba84fc8da31e0038350bc8fce34b11d419f3da8e369" name = "golang.org/x/crypto" packages = [ "pbkdf2", "ripemd160", "scrypt", - "ssh/terminal" + "ssh/terminal", ] + pruneopts = "UT" revision = "374053ea96cb300f8671b8d3b07edeeb06e203b4" [[projects]] branch = "master" + digest = "1:b67fb09eb3d3c8026356f78ca24a1a74d8c551f60746fe647a6f1cedf460abbd" name = "golang.org/x/sys" packages = [ "unix", - "windows" + "windows", ] + pruneopts = "UT" revision = "2f1e207ee39ff70f3433e49c6eb52677a515e3b5" [[projects]] + digest = "1:8029e9743749d4be5bc9f7d42ea1659471767860f0cdc34d37c3111bd308a295" name = "golang.org/x/text" packages = [ "internal/gen", @@ -117,24 +147,43 @@ "internal/ucd", "transform", "unicode/cldr", - "unicode/norm" + "unicode/norm", ] + pruneopts = "UT" revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" [[projects]] branch = "master" + digest = "1:3bb904aa43844ed7773faff747e121d8ff37c32c552f8c88f107160831d32f59" name = "golang.org/x/tools" packages = [ "go/ast/astutil", "go/buildutil", - "go/loader" + "go/loader", ] + pruneopts = "UT" revision = "96caea41033df6f8c3974c845ab094f8ec3bd345" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "a78ff5fce460573a959ec1ce2f81125252c2e8c55a4c5ca8e903937ec089964a" + input-imports = [ + "github.com/anthdm/rfc6979", + "github.com/go-redis/redis", + "github.com/go-yaml/yaml", + "github.com/pkg/errors", + "github.com/sirupsen/logrus", + "github.com/stretchr/testify/assert", + "github.com/stretchr/testify/require", + "github.com/syndtr/goleveldb/leveldb", + "github.com/syndtr/goleveldb/leveldb/opt", + "github.com/syndtr/goleveldb/leveldb/util", + "github.com/urfave/cli", + "golang.org/x/crypto/ripemd160", + "golang.org/x/crypto/scrypt", + "golang.org/x/text/unicode/norm", + "golang.org/x/tools/go/loader", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/circle.yml b/circle.yml index 59a6387f4..2872afeda 100644 --- a/circle.yml +++ b/circle.yml @@ -9,10 +9,10 @@ jobs: steps: - checkout - restore_cache: - key: dependency-cache-{{ checksum "Gopkg.toml" }} + key: dependency-cache-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }} - run: /scripts/build.sh - save_cache: - key: dependency-cache-{{ checksum "Gopkg.toml" }} + key: dependency-cache-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }} paths: - vendor - /go/pkg @@ -28,7 +28,7 @@ jobs: - dependency-cache-{{ .Revision }} - restore_cache: keys: - - dependency-cache-cli-{{ checksum "Gopkg.toml" }} + - dependency-cache-cli-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }} - setup_remote_docker - run: name: Install Docker client @@ -46,7 +46,7 @@ jobs: steps: - checkout - restore_cache: - key: dependency-cache-{{ checksum "Gopkg.toml" }} + key: dependency-cache-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }} - run: make test vet: working_directory: /go/src/github.com/CityOfZion/neo-go @@ -55,7 +55,7 @@ jobs: steps: - checkout - restore_cache: - key: dependency-cache-{{ checksum "Gopkg.toml" }} + key: dependency-cache-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }} - run: make vet build_cli: working_directory: /go/src/github.com/CityOfZion/neo-go @@ -64,10 +64,10 @@ jobs: steps: - checkout - restore_cache: - key: dependency-cache-{{ checksum "Gopkg.toml" }} + key: dependency-cache-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }} - run: make build - save_cache: - key: dependency-cache-cli-{{ checksum "Gopkg.toml" }} + key: dependency-cache-cli-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }} paths: - bin/neo-go deploy: @@ -78,9 +78,9 @@ jobs: - run: apk update && apk add git make curl tar - checkout - restore_cache: - key: dependency-cache-{{ checksum "Gopkg.toml" }} + key: dependency-cache-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }} - restore_cache: - key: dependency-cache-cli-{{ checksum "Gopkg.toml" }} + key: dependency-cache-cli-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }} - setup_remote_docker - run: name: Install Docker client @@ -137,4 +137,4 @@ workflows: only: - /[0-9]+\.[0-9]+\.[0-9]+/ branches: - ignore: /.*/ + ignore: /.*/ \ No newline at end of file diff --git a/pkg/rpc/server_test.go b/pkg/rpc/server_test.go index 9bc923deb..d22f65d47 100644 --- a/pkg/rpc/server_test.go +++ b/pkg/rpc/server_test.go @@ -26,13 +26,17 @@ type tc struct { var testRpcCases = []tc{ - {`{"jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": ["602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"] }`, - "getassetstate_1", - `{"jsonrpc":"2.0","result":{"assetId":"0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7","assetType":1,"name":"NEOGas","amount":"100000000","available":"0","precision":8,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"AWKECj9RD8rS8RPcpCgYVjk1DeYyHwxZm3","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`}, + { + rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": ["602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"] }`, + method: "getassetstate_1", + expectedResult: `{"jsonrpc":"2.0","result":{"assetId":"0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7","assetType":1,"name":"NEOGas","amount":"100000000","available":"0","precision":8,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"AWKECj9RD8rS8RPcpCgYVjk1DeYyHwxZm3","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`, + }, - {`{ "jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": ["c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b"] }`, - "getassetstate_2", - `{"jsonrpc":"2.0","result":{"assetId":"0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b","assetType":0,"name":"NEO","amount":"100000000","available":"0","precision":0,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`}, + { + rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": ["c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b"] }`, + method: "getassetstate_2", + expectedResult: `{"jsonrpc":"2.0","result":{"assetId":"0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b","assetType":0,"name":"NEO","amount":"100000000","available":"0","precision":0,"fee":0,"address":"0x0000000000000000000000000000000000000000","owner":"00","admin":"Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":0,"is_frozen":false},"id":1}`, + }, { rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getassetstate", "params": ["62c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"] }`, @@ -46,9 +50,11 @@ var testRpcCases = []tc{ expectedResult: `{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params"},"id":1}`, }, - {`{"jsonrpc": "2.0", "id": 1, "method": "getblockhash", "params": [10] }`, - "getblockhash_1", - `{"jsonrpc":"2.0","result":"0xd69e7a1f62225a35fed91ca578f33447d93fa0fd2b2f662b957e19c38c1dab1e","id":1}`}, + { + rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getblockhash", "params": [10] }`, + method: "getblockhash_1", + expectedResult: `{"jsonrpc":"2.0","result":"0xd69e7a1f62225a35fed91ca578f33447d93fa0fd2b2f662b957e19c38c1dab1e","id":1}`, + }, { rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getblockhash", "params": [-2] }`, @@ -56,25 +62,34 @@ var testRpcCases = []tc{ expectedResult: `{"jsonrpc":"2.0","error":{"code":-32603,"message":"Internal error","data":"Internal server error"},"id":1}`, }, - {`{"jsonrpc": "2.0", "id": 1, "method": "getblock", "params": [10] }`, - "getblock", - `{"jsonrpc":"2.0","result":{"version":0,"previousblockhash":"0x7c5b4c8a70336bf68e8679be7c9a2a15f85c0f6d0e14389019dcc3edfab2bb4b","merkleroot":"0xc027979ad29226b7d34523b1439a64a6cf57fe3f4e823e9d3e90d43934783d26","time":1529926220,"height":10,"nonce":8313828522725096825,"next_consensus":"0xbe48d3a3f5d10013ab9ffee489706078714f1ea2","script":{"invocation":"40ac828e1c2a214e4d356fd2eccc7c7be9ef426f8e4ea67a50464e90ca4367e611c4c5247082b85a7d5ed985cfb90b9af2f1195531038f49c63fb6894b517071ea40b22b83d9457ca5c4c5bb2d8d7e95333820611d447bb171ce7b8af3b999d0a5a61c2301cdd645a33a47defd09c0f237a0afc86e9a84c2fe675d701e4015c0302240a6899296660c612736edc22f8d630927649d4ef1301868079032d80aae6cc1e21622f256497a84a71d7afeeef4c124135f611db24a0f7ab3d2a6886f15db7865","verification":"532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"},"tx":[{"type":"MinerTransaction","version":0,"attributes":null,"vin":null,"vout":null,"scripts":null}],"confirmations":12338,"nextblockhash":"0x2b1c78633dae7ab81f64362e0828153079a17b018d779d0406491f84c27b086f","hash":"0xd69e7a1f62225a35fed91ca578f33447d93fa0fd2b2f662b957e19c38c1dab1e"},"id":1}`}, + { + rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getblock", "params": [10] }`, + method: "getblock", + expectedResult: `{"jsonrpc":"2.0","result":{"version":0,"previousblockhash":"0x7c5b4c8a70336bf68e8679be7c9a2a15f85c0f6d0e14389019dcc3edfab2bb4b","merkleroot":"0xc027979ad29226b7d34523b1439a64a6cf57fe3f4e823e9d3e90d43934783d26","time":1529926220,"height":10,"nonce":8313828522725096825,"next_consensus":"0xbe48d3a3f5d10013ab9ffee489706078714f1ea2","script":{"invocation":"40ac828e1c2a214e4d356fd2eccc7c7be9ef426f8e4ea67a50464e90ca4367e611c4c5247082b85a7d5ed985cfb90b9af2f1195531038f49c63fb6894b517071ea40b22b83d9457ca5c4c5bb2d8d7e95333820611d447bb171ce7b8af3b999d0a5a61c2301cdd645a33a47defd09c0f237a0afc86e9a84c2fe675d701e4015c0302240a6899296660c612736edc22f8d630927649d4ef1301868079032d80aae6cc1e21622f256497a84a71d7afeeef4c124135f611db24a0f7ab3d2a6886f15db7865","verification":"532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"},"tx":[{"type":"MinerTransaction","version":0,"attributes":null,"vin":null,"vout":null,"scripts":null}],"confirmations":12338,"nextblockhash":"0x2b1c78633dae7ab81f64362e0828153079a17b018d779d0406491f84c27b086f","hash":"0xd69e7a1f62225a35fed91ca578f33447d93fa0fd2b2f662b957e19c38c1dab1e"},"id":1}`, + }, - {`{"jsonrpc": "2.0", "id": 1, "method": "getblockcount", "params": [] }`, - "getblockcount", - `{"jsonrpc":"2.0","result":12349,"id":1}`}, + { + rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getblockcount", "params": [] }`, + method: "getblockcount", + expectedResult: `{"jsonrpc":"2.0","result":12349,"id":1}`, + }, - {`{"jsonrpc": "2.0", "id": 1, "method": "getconnectioncount", "params": [] }`, - "getconnectioncount", - `{"jsonrpc":"2.0","result":0,"id":1}`}, + { + rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getconnectioncount", "params": [] }`, + method: "getconnectioncount", + expectedResult: `{"jsonrpc":"2.0","result":0,"id":1}`, + }, - {`{"jsonrpc": "2.0", "id": 1, "method": "getbestblockhash", "params": [] }`, - "getbestblockhash", - `{"jsonrpc":"2.0","result":"877f5f2084181b85ce4726ab0a86bea6cc82cdbcb6f2eb59e6b04d27fd10929c","id":1}`}, + { + rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getbestblockhash", "params": [] }`, + method: "getbestblockhash", + expectedResult: `{"jsonrpc":"2.0","result":"877f5f2084181b85ce4726ab0a86bea6cc82cdbcb6f2eb59e6b04d27fd10929c","id":1}`, + }, - {`{"jsonrpc": "2.0", "id": 1, "method": "getpeers", "params": [] }`, - "getpeers", - `{"jsonrpc":"2.0","result":{"unconnected":[],"connected":[],"bad":[]},"id":1}`}, + { + rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getpeers", "params": [] }`, + method: "getpeers", + expectedResult: `{"jsonrpc":"2.0","result":{"unconnected":[],"connected":[],"bad":[]},"id":1}`}, // Good case, valid transaction ((param[1]=1 -> verbose = 1)) { @@ -224,8 +239,7 @@ func TestHandler(t *testing.T) { rpcCall: `{"jsonrpc": "2.0", "id": 1, "method": "getversion", "params": [] }`, method: "getversion", expectedResult: fmt.Sprintf(`{"jsonrpc":"2.0","result":{"port":20333,"nonce":%s,"useragent":"/NEO-GO:/"},"id":1}`, strconv.FormatUint(uint64(server.ID()), 10)), - }, - ) + }) for _, tc := range testRpcCases { t.Run(fmt.Sprintf("method: %s, rpc call: %s", tc.method, tc.rpcCall), func(t *testing.T) { @@ -238,7 +252,7 @@ func TestHandler(t *testing.T) { resp := w.Result() body, err := ioutil.ReadAll(resp.Body) assert.NoErrorf(t, err, "could not read response from the request: %s", tc.rpcCall) - assert.Equal(t, tc.expectedResult, string(bytes.TrimSpace(body))) + assert.JSONEq(t, tc.expectedResult, string(bytes.TrimSpace(body))) }) }