Fix kitchen_sink.sh. Add tests for base32 encoder

This commit is contained in:
Netscape Navigator 2020-04-06 07:18:04 -05:00
parent dd455ff1df
commit 6d6e8ffa37
5 changed files with 42 additions and 58 deletions

View File

@ -45,13 +45,14 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`.
- [X] 100% test coverage
- [X] Implement pigeon message find-all for peer feed. I will need to add index for `author => message_count`
- [X] Switch to Crockford base32- Simplifies support for legacy systems. Easy to implement.
- [ ] Need a way of importing / exporting a feeds blobs. (see "Bundle Brainstorming" below)
- [ ] Need a way of adding a peers messages / blobs to bundles. (see "Bundle Brainstorming" below)
- [ ] refactor `Bundle.create` to use `message find-all`.
- [ ] Add mandatory `--from=` arg to `bundle create`
- [ ] Make the switch to LevelDB, RocksDB or similar (currently using Ruby PStore).
- [ ] Change all multihashes to Base32 to support case-insensitive file systems?
- [X] Fix `scratchpad.sh` to use Base32
- [ ] Rename (RemoteIdentity|LocalIdentity)#public_key to #multihash for consistency with other types.
- [ ] refactor `Bundle.create` to use `message find-all`.
- [ ] Need a way of importing / exporting a feeds blobs. (see "Bundle Brainstorming" below)
- [ ] Need a way of adding peers messages / gossip to bundles. (see "Bundle Brainstorming" below)
- [ ] Add Lipmaa links like the Bamboo folks do.
- [ ] Add mandatory `--since=` arg to `bundle create`
- [ ] Make the switch to LevelDB, RocksDB or similar (currently using Ruby PStore).
- [ ] Rename `message find` to `message read`, since other finders return a multihash.
- [ ] Don't allow any type of whitespace in `kind` or `string` keys. Write a test for this.
- [ ] Check block list before ingesting bundles.
@ -62,8 +63,6 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`.
- [ ] Reduce whole darn repo into single module to aide portability. Maybe a second `::Support` module is OK.
- [ ] Update the bundles.md document once `bundle consume` works.
- [ ] Use URNs instead of multihash?
- [ ] Add `.pigeon` file extensions
- [ ] Add Lipmaa links like the Bamboo folks do.
- [ ] Ensure all disks writes perform verification!
- [ ] Publish a RubyGem
- [ ] 100% documentation
@ -92,4 +91,9 @@ Here's how we will support that:
Additional notes:
* It is recommended to compress bundles (ex: *.zip files) but these concerns are not handled by the protocol currently.
* It is recommended to compress bundles (ex: *.zip files) but these concerns are not handled by the protocol currently.
# Unanswered Questions
* PEER MESSAGES: I want to add a `--depth` option to bundle exports that would only return messages after the `nth` sequence number. It would not make sense to apply `--depth` to all peer messages in the bundle. It would not be practical to expect the user to provide a `--depth` for every peer every time a bundle is generated.
* Create a new `received_on` index that records the local user's `depth` at the time of ingestion?

1
dist/pigeon.rb vendored
View File

@ -1,6 +1,7 @@
require "digest"
require "ed25519"
require "securerandom"
require "set"
# Remove this when we launch or add ENVs:
require "pry"

34
scratchpad.sh → kitchen_sink.sh Executable file → Normal file
View File

@ -17,24 +17,24 @@ echo "Creating kitty cat blobs:"
cat scratchpad.jpg | ./pigeon-cli blob set
echo "Adding peers:"
echo "FIX THESE!!! THEY ARE STILL b64"
./pigeon-cli peer add @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer add @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer add @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer add @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer add @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer add @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer add @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer add @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer add @ZMS36YMSTYC19EX8AS07G0XAYEK643YM6SB6NYWATMEBSS92BVH0.ed25519
./pigeon-cli peer add @3EEQ2ETD23DYS1SWBQ373796TR8W865EBWHYAFPBZ8YA2FRCR0YG.ed25519
./pigeon-cli peer add @Y9DG9GZMWJPRW47D0MGMTJNV0PQPFANW7Q5J05PXT0ZNY9PMCZGG.ed25519
./pigeon-cli peer add @WPFKCW2B9SDKBY7NNTVEV7TBZVTEH6J21NXNHQR3006GT1H8PEW0.ed25519
./pigeon-cli peer add @C1KG390SFSZ49P824GNCTP7YF8ZM2SCFGGFBNHBKEKZYGPYTZYX0.ed25519
./pigeon-cli peer add @W1FJYN9ZKZHMBTW8Q8DCVB8YVE5Y7Z896BSM85XEFKXZWPG70W70.ed25519
./pigeon-cli peer add @X5HCRRVH33J0EDJ42JJ193GVA2KDQ9ZW0RQ8RM9MVVPQVXQQC100.ed25519
./pigeon-cli peer add @0Y82485FV56XRBZYT8DRRYPTE36J8NRN5979NE8EXNRMS4JVQMSG.ed25519
echo "removing peers:"
./pigeon-cli peer remove @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer remove @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer remove @G28JPBYGNCPE19C32083CDGA0KBKVF5HFJPPDEC8J7CMR3CCBCC0.ed25519
./pigeon-cli peer remove @YWK61TMCZS4WP0R9R3MKKF8HXVJCPTHMXY3NAQH5CQZVCSBRC4V0.ed25519
echo "blocking peers:"
./pigeon-cli peer block @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer block @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer block @CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli peer block @5NDF5NSJZCKDGJ5C5EXN4Q4NERXA8QTK3AKJTC9Y5E4K3J42H9E0.ed25519
./pigeon-cli peer block @4MAA3HFRDHFK3H6EEDGE4DTAPP2T7TP2VD8G1X9AHDVXX7AMPA7G.ed25519
./pigeon-cli peer block @41FNE08J5XK9GEV1BTEPT15WW1KDK5XCC8SMM62MQNYZ0785NJ80.ed25519
echo "listing all peers:"
./pigeon-cli peer all
@ -55,13 +55,13 @@ echo "...string with quotes"
./pigeon-cli draft append key3 "my_value3"
echo "...draft ID"
./pigeon-cli draft append key4 \%CHANGE_THIS_TO_BASE_32.sha256
./pigeon-cli draft append key4 \%4Q7K6A1RW3XEHWFKWTN8SP2M0Q0PXSWPBCFVCZFGM3TAKM6G34SG.sha256
echo "...blob"
./pigeon-cli draft append key5 \&CHANGE_THIS_TO_BASE_32.sha256
./pigeon-cli draft append key5 \&Y2WZTXD32DNNVPPWVRZ15G2NKTPJTQ6BDW4M14D3NJ38NV3064D0.sha256
echo "...identity"
./pigeon-cli draft append key6 \@CHANGE_THIS_TO_BASE_32.ed25519
./pigeon-cli draft append key6 \@VTE8VPT2S6CM50C2VBPGDHZAP7BWKGZXBVVX0ZPPMDRQ05FV8G80.ed25519
echo "== show draft"
./pigeon-cli draft show

View File

@ -0,0 +1,11 @@
RSpec.describe Pigeon::Helpers do
it "handles Crockford Base 32 values" do
10.times do
raw_bytes = SecureRandom.random_bytes(32)
encoded_bytes = Pigeon::Helpers.b32_encode(raw_bytes)
decoded_bytes = Pigeon::Helpers.b32_decode(encoded_bytes)
expect(raw_bytes).to eq(decoded_bytes)
end
end
end

View File

@ -1,32 +0,0 @@
require "spec_helper"
RSpec.describe "Kitch sink spec" do
it "does everything" do
kp = Pigeon::LocalIdentity.new()
kp.save!
Pigeon::LocalIdentity.current.public_key
# ./pigeon-cli identity new
# ./pigeon-cli identity show
# cat scratchpad.jpg | ./pigeon-cli blob set
# ./pigeon-cli peer add @_TlC2z3FT4fimecC4eytrBhOwhLUZsVBZEZriBO9cWs=.ed25519
# ./pigeon-cli peer add @28FyT7evjcYrrwngr8G2V1HZ0ODK0VPsFctDEZwfZJc=.ed25519
# ./pigeon-cli peer remove @mYWRsosFtoxvn3GURmmE0FVtOWPcYv4ovXIAqy49sH4=.ed25519
# ./pigeon-cli peer remove @Nf7ZU9fLwukgfRfCunDtfjXRlhitiR-DcTmlNhB8lwk=.ed25519
# ./pigeon-cli peer block @q-_9BTnTThvW2ZGkmy8D3j-hW9ON2PNa3nwbCQgRw-g=.ed25519
# ./pigeon-cli peer block @VIim19-PzaavRICicQg4c4z08SoWTa1tr2e-kfhmm0Y=.ed25519
# ./pigeon-cli peer all
# ./pigeon-cli message create scratch_pad
# echo "my_value" | ./pigeon-cli message append key1
# ./pigeon-cli message append key2 my_value2
# ./pigeon-cli message append key3 "my_value3"
# ./pigeon-cli message append key4 \%jvKh9yoiEJaePzoWCF1nnqpIlPgTk9FHEtqczQbvzGM=.sha256
# ./pigeon-cli message append key5 \&29f3933302c49c60841d7620886ce54afc68630242aee6ff683926d2465e6ca3.sha256
# ./pigeon-cli message append key6 \@galdahnB3L2DE2cTU0Me54IpIUKVEgKmBwvZVtWJccg=.ed25519
# ./pigeon-cli message show
# ./pigeon-cli message sign
# ./pigeon-cli message create second_test
# ./pigeon-cli message append hello "world"
# ./pigeon-cli message sign
# ./pigeon-cli status
end
end