Test case: Verification / assertion error
This commit is contained in:
parent
cf8232d2d7
commit
b0181234af
|
@ -67,7 +67,7 @@ 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("depth", count, depth)
|
||||
assert("prev", prev, expected_prev)
|
||||
end
|
||||
|
||||
|
|
|
@ -22,12 +22,7 @@ RSpec.describe Pigeon::Message do
|
|||
expect(expected_bundle).to eq(actual_bundle)
|
||||
end
|
||||
|
||||
it "debugs a problem" do
|
||||
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)
|
||||
public_key = "@NYTrqYYN2ffTqFyPCUULjhhUkfbY9LorpWYMoMpsOO4=.ed25519"
|
||||
expect(Pigeon::LocalIdentity.current.public_key).to eq(public_key)
|
||||
it "does not crash when ingesting old messages" do
|
||||
create_fake_messages
|
||||
Pigeon::Bundle.create
|
||||
Pigeon::Bundle.ingest
|
||||
|
|
|
@ -118,4 +118,19 @@ RSpec.describe Pigeon::Message do
|
|||
expect(message.signature).to eq(sig1_b64)
|
||||
expect(message.signature).to eq(sig2_b64)
|
||||
end
|
||||
|
||||
it "crashes on forged fields" do
|
||||
msg = Pigeon::Parser.parse([
|
||||
[:AUTHOR, "@DYdgK1KUInVtG3lS45hA1HZ-jTuvfLKsxDpXPFCve04=.ed25519"],
|
||||
[:KIND, "invalid"],
|
||||
[:PREV, "NONE"],
|
||||
[:DEPTH, 10],
|
||||
[:HEADER_END],
|
||||
[:BODY_ENTRY, "duplicate", "This key is a duplicate."],
|
||||
[:SIGNATURE, "DN7yPTE-m433ND3jBL4oM23XGxBKafjq0Dp9ArBQa_TIGU7DmCxTumieuPBN-NKxlx_0N7-c5zjLb5XXVHYPCQ==.sig.ed25519"],
|
||||
[:MESSAGE_END],
|
||||
])
|
||||
m = "Expected field `depth` to equal 0, got: 10"
|
||||
expect { msg.first.save! }.to raise_error(Pigeon::Message::VerificationError, m)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue