Works again! 🎉

This commit is contained in:
Netscape Navigator 2020-04-03 05:19:42 -05:00
parent 6b71044e86
commit cf8232d2d7
4 changed files with 9 additions and 3 deletions

View File

@ -41,7 +41,9 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`.
- [X] Put all the [HEADER, string, FOOTER].join("") nonsense into Pigeon::Helpers
- [X] Use raw SHA256 hashes for blob multihashes, not hex.
- [X] Change all the `{40,90}` values in ::Lexer to real length values
- [ ] Is it possible signature verification is failing beecause a CR is being prepended to the front?
- [X] Don't double-ingest messages. It will screw up indexes.
- [ ] Handle the three outcomes of bundle ingestion: `ok`, `blocked`, `already_saved`.
- [ ] Check blocklist before ingesting bundles.
- [ ] Rename (RemoteIdentity|LocalIdentity)#public_key to #multihash for consistency with other types.
- [ ] Rename `message find` to `message read`, since other finders return a multihash.
- [ ] Don't allow carriage return in `kind` or `string` keys. Write a test for this.

View File

@ -46,6 +46,7 @@ module Pigeon
end
def save!
return store.find_message(multihash) if store.message?(multihash)
calculate_signature
verify_depth_prev_and_depth
verify_signature
@ -66,7 +67,6 @@ module Pigeon
def verify_depth_prev_and_depth
count = store.get_message_count_for(author.public_key)
expected_prev = store.get_message_by_depth(author.public_key, count - 1) || Pigeon::EMPTY_MESSAGE
assert("depth", depth, count)
assert("prev", prev, expected_prev)
end
@ -88,6 +88,7 @@ module Pigeon
def calculate_signature
return if @signature
#TODO: Verify that the author is Pigeon::LocalIdentity.current?
@signature = author.sign(template.render_without_signature)
end

View File

@ -41,6 +41,10 @@ module Pigeon
read { store[MESG_NS].fetch(multihash) }
end
def message?(multihash)
read { store[MESG_NS].fetch(multihash, false) }
end
def find_all(author = Pigeon::LocalIdentity.current.public_key)
# TODO: Ability to pass an author ID to `find-all`
store = Pigeon::Storage.current

View File

@ -23,7 +23,6 @@ RSpec.describe Pigeon::Message do
end
it "debugs a problem" do
pending("Pigeon::Bundle.ingest is broke. Will fix after investigation.")
seed = "\xA3@\x12\xA6\x8Cl\x83\xF5)\x97\xED\xE67\x91\xAD\xFD\xCFf\xF4(\xEF\x81P\xBBD\xF7\x8C\xF7\x8D\xC0\xA9\f"
ident = Pigeon::LocalIdentity.new(seed)
Pigeon::LocalIdentity.instance_variable_set(:@current, ident)