holochain / holochain-proto

Holographic storage for distributed applications -- a validating monotonic DHT "backed" by authoritative hashchains for data provenance (a Ceptr sub-project)
http://holochain.org
GNU General Public License v3.0
878 stars 144 forks source link

`const` in `node.go` is fragile to reordering #713

Open thedavidmeister opened 6 years ago

thedavidmeister commented 6 years ago

Noticed in #698

git__ ___go_src_github_com_holochain_holochain-proto

In node.go the constants are grouped by purpose, e.g. "DHT messages", "Validate messages", etc.

But the value of the constants is determined by their ordering.

For example, adding MIGRATE_REQUEST before PUT_REQUEST causes tests to fail due to PUT_REQUEST changing from 2 to 3.

Most of the constants have no tests ensuring their value, so a change of order can accidentally revalue some or all the constants.

These constants should ideally not be changing across versions.

zippy commented 6 years ago

Yes, this is true. They get a sequence value from the iota, and they actually are very sensitive because they implicitly part of the line protocol as remote nodes use the values to figure out which network action is meant. In a way the current tests which use "%v" to print out the values of a packet actually do test this correctly in that they make your code break if you change the ordering. They just don't do so explicitly so that you know what happened.

thedavidmeister commented 6 years ago

there are explicit tests in #698 at least for these consts