210 Commits

Author SHA1 Message Date
Lars Gierth
e791f319f0 Add conformance testing
This patch adds a go-multiaddr CLI to aid in testing this
implementation of multiaddr. It takes a multiaddr in string or
packed form as input, and prints detailed information about the
multiaddr. This tool can be useful beyond testing, of course.

Another addition is a Makefile target for running the new
multiaddr conformance test suite. This test suite lives at
https://github.com/multiformats/multiaddr and is fetched to be
run against our new go-multiaddr CLI. This target is to be run in CI

Neither the test suite nor the CLI are complete yet.

Currently the output looks like this:

```
> go run ./multiaddr /ip4/192.0.2.42/tcp/443 | jq .
{
  "string": "/ip4/192.0.2.42/tcp/443",
  "stringSize": "23",
  "packed": "0x04c000022a0601bb",
  "packedSize": "8",
  "components": [
    {
      "string": "/ip4/192.0.2.42",
      "stringSize": "15",
      "packed": "0x04c000022a",
      "packedSize": "5",
      "value": "192.0.2.42",
      "rawValue": "0xc000022a",
      "valueSize": "4",
      "protocol": "ip4",
      "codec": "4",
      "uvarint": "0x04",
      "lengthPrefix": ""
    },
    {
      "string": "/tcp/443",
      "stringSize": "8",
      "packed": "0x0601bb",
      "packedSize": "3",
      "value": "443",
      "rawValue": "0x01bb",
      "valueSize": "2",
      "protocol": "tcp",
      "codec": "6",
      "uvarint": "0x06",
      "lengthPrefix": ""
    }
  ]
}
```

And the Makefile target:

```
> make conformance
go get -d -v .
go build -o tmp/multiaddr/test/go-multiaddr ./multiaddr
cd tmp/multiaddr/test && MULTIADDR_BIN="./go-multiaddr" go test -v
=== RUN   TestGodog
MULTIADDR_BIN="./go-multiaddr"
Feature: Multiaddr

  Scenario: Banana                              # multiaddr.feature:3
    Given the multiaddr /ip4/192.0.2.42/tcp/443 # main_test.go:81 -> github.com/multiformats/multiaddr/test_test.theMultiaddr
    Then the packed form is 0x04c000022a0601bb  # main_test.go:98 -> github.com/multiformats/multiaddr/test_test.thePackedFormIs
    And the packed size is 8 bytes              # main_test.go:105 -> github.com/multiformats/multiaddr/test_test.thePackedSizeIs
    And the components are:                     # main_test.go:126 -> github.com/multiformats/multiaddr/test_test.theComponentsAre
      | string          | stringSize | packed       | packedSize | value      | valueSize | protocol | codec | uvarint | lengthPrefix | rawValue   |
      | /ip4/192.0.2.42 | 15         | 0x04c000022a | 5          | 192.0.2.42 | 4         | ip4      | 4     | 0x04    |              | 0xc000022a |
      | /tcp/443        | 8          | 0x0601bb     | 3          | 443        | 2         | tcp      | 6     | 0x06    |              | 0x01bb     |

  Scenario: Banana #2                               # multiaddr.feature:12
    Given the multiaddr 0x04c000022a0601bb          # main_test.go:81 -> github.com/multiformats/multiaddr/test_test.theMultiaddr
    Then the string form is /ip4/192.0.2.42/tcp/443 # main_test.go:112 -> github.com/multiformats/multiaddr/test_test.theStringFormIs
    And the string size is 23 bytes                 # main_test.go:119 -> github.com/multiformats/multiaddr/test_test.theStringSizeIs
    And the components are:                         # main_test.go:126 -> github.com/multiformats/multiaddr/test_test.theComponentsAre
      | string          | stringSize | packed       | packedSize | value      | valueSize | protocol | codec | uvarint | lengthPrefix | rawValue   |
      | /ip4/192.0.2.42 | 15         | 0x04c000022a | 5          | 192.0.2.42 | 4         | ip4      | 4     | 0x04    |              | 0xc000022a |
      | /tcp/443        | 8          | 0x0601bb     | 3          | 443        | 2         | tcp      | 6     | 0x06    |              | 0x01bb     |

2 scenarios (2 passed)
8 steps (8 passed)
3.187755ms
--- PASS: TestGodog (0.00s)
PASS
ok  	github.com/multiformats/multiaddr/test	0.012s
```
2019-04-19 05:15:55 +02:00
Jakub Sztandera
ce21123d51
Merge pull request #98 from multiformats/fix/todo
trivial: remove stale TODO
2019-02-27 14:10:35 +01:00
Raúl Kripalani
794e406662
remove stale TODO. 2019-02-27 12:10:50 +00:00
Hector Sanjuan
994311756b
Merge pull request #95 from multiformats/marshalers
Let Multiaddr implement marshalers: binary, text, json
2019-02-26 19:48:16 +00:00
Hector Sanjuan
21e652556d gx publish 1.4.1 2019-02-26 19:41:46 +00:00
Jakub Sztandera
06f7d80ada
Merge pull request #96 from multiformats/feat/better-travis
Update travis config
2019-02-26 19:07:01 +01:00
Jakub Sztandera
b5f1479548 Update travis config 2019-02-26 18:50:55 +01:00
Hector Sanjuan
0aa80854ab Let Multiaddr implement marshalers: binary, text, json 2019-02-25 22:48:24 +00:00
Jakub Sztandera
0297994296
Merge pull request #94 from multiformats/feat/gomod
Add go.mod support
2019-02-25 13:00:24 +01:00
Jakub Sztandera
f5b8871dd9 Add go.mod support 2019-02-25 11:53:48 +01:00
Jakub Sztandera
19d7396df1
Merge pull request #89 from multiformats/fix/captain
README: remove out of date captain
2019-02-20 15:20:57 +01:00
Steven Allen
152990b98b
Merge pull request #93 from backkem/p2p-webrtc-direct
Add p2p-webrtc-direct protocol
2018-12-27 14:37:46 -08:00
backkem
6b421eaeda Add p2p-webrtc-direct protocol 2018-12-20 12:10:18 +01:00
Steven Allen
312b9db355
Merge pull request #87 from RTradeLtd/master
onionv3 and i2p base64 addresses
2018-12-18 17:13:04 -08:00
idk
f60a1c99ee
unrewrite path 2018-12-18 10:24:02 -05:00
idk
b0582d3730
make suggested changes, pre-compute garlicBase64Encoding, simplify garlicValidate, check length of bytes 2018-12-18 10:22:35 -05:00
idk
ac6bfc1dd2
fix broken validation 2018-12-15 01:44:59 -05:00
idk
04300cfb45
fix unreturned fmt.Errorf 2018-12-15 01:24:59 -05:00
Steven Allen
f8a18bb2f1
Merge pull request #91 from anacrolix/fix/missing-addr-protocol-name
Use the original protocol name for address missing errors
2018-12-14 10:51:43 -08:00
Matt Joiner
6f524a4380 Use the original protocol name for address missing errors
Reduces confusion due to aliased protocol names.

License: MIT
Signed-off-by: Matt Joiner <anacrolix@gmail.com>
2018-12-14 19:37:13 +11:00
idk
567daf242f
made garlic64 variable-length 2018-12-13 04:53:17 -05:00
Steven Allen
73950681ca
Merge pull request #90 from anacrolix/patch-1
Add GoDoc badge
2018-12-11 15:17:43 -08:00
Matt Joiner
07c7f15f48
Add GoDoc badge
License: MIT
Signed-off-by: Matt Joiner <anacrolix@gmail.com>
2018-12-12 10:10:23 +11:00
Steven Allen
7767401dbd README: remove out of date captain 2018-12-10 13:12:50 -08:00
Cole Brown
8c3eb5dc1c gx publish 1.4.0 2018-12-04 17:46:38 -05:00
idk
0f1c1ba00d
remove garlic32 protocol 2018-11-30 22:48:29 -05:00
idk
684664541d
switch back to P_ONION and remove P_ONION2 alias 2018-11-30 20:09:02 -05:00
idk
a91caf054e
add both base64 and base32 addresses as separate protocols, remove port from addresses to be expressed as /tcp, etc. 2018-11-30 19:55:52 -05:00
Steven Allen
0523e08ac1
Merge pull request #88 from bigs/bug/varintsize
Fix bug in VarintSize
2018-11-29 16:16:22 -08:00
Steven Allen
11c75668d3 test: test all varints less than 2**16 againt VarintSize 2018-11-29 16:08:46 -08:00
Cole Brown
d462e342b7 Fix yet another bug in VarintSize, add test 2018-11-29 18:58:36 -05:00
Cole Brown
1a8ba0918f Fix bug in VarintSize
:100644 100644 79ebe2f b0ced77 M	varint.go
2018-11-29 18:13:54 -05:00
idk
789405bd40
remove log 2018-11-27 18:17:51 -05:00
idk
2a21023817
Merge branch 'master' of https://github.com/multiformats/go-multiaddr 2018-11-27 13:04:45 -05:00
idk
fb27f336e7
better test message for failure to convert x to y 2018-11-27 12:58:26 -05:00
idk
01a9048ee5
re-enable the tests 2018-11-27 12:53:46 -05:00
idk
4619045f0d
finish switching to base64 addresses for garlic-routed requests. This is so we can have both the base64 and base32 keys. 2018-11-26 05:03:37 -05:00
idk
54ddf83b00
Switch to using base64 i2p addresses to facilitate transport 2018-11-26 05:03:37 -05:00
idk
58c18c3ad6
Switch to using base64 i2p addresses to facilitate transport 2018-11-25 15:27:27 -05:00
idk
cf7ed7c1ad
created onionv3 and garlic multiaddrs 2018-11-15 04:11:07 -05:00
Steven Allen
ec8630b6b7 Merge branch 'gx/update-fzw9j3' 2018-11-02 16:06:47 -07:00
Steven Allen
8dc8c4a64c gx publish 1.3.6 2018-11-02 15:54:33 -07:00
Steven Allen
393301199b gx publish 1.3.5 2018-10-18 11:19:28 +01:00
Steven Allen
d237243b4a
Merge pull request #84 from multiformats/fix/shortcut-split-component
shortcut split on components
2018-10-18 10:43:51 +01:00
Steven Allen
faf8963c9a fix zone validator
(bug caught by fuzzer)
2018-10-18 10:35:11 +01:00
Steven Allen
877fe6538c shortcut split on components
Instead of re-parsing single-components, shortcut split/for-each functions.
2018-10-18 10:32:13 +01:00
Steven Allen
dda950c1d3 gx publish 1.3.4 2018-10-16 16:57:21 +01:00
Steven Allen
021d073ecd Merge branch 'feat/component' 2018-10-16 16:57:14 +01:00
Steven Allen
fa28600751 gx publish 1.3.3 2018-10-16 16:50:53 +01:00
Steven Allen
42326a8c13
Merge pull request #79 from multiformats/nit/cleanup
small cleanups and optimizations
2018-10-16 16:38:27 +01:00