Stub out an `importBundle` file
This commit is contained in:
parent
d930e68e53
commit
651783eb59
|
@ -33,14 +33,19 @@ Email `contact@vaporsfot.xyz` if you have any questions.
|
||||||
- [ ] Switch to [SQLX](https://github.com/jmoiron/sqlx) for extra sanity.
|
- [ ] Switch to [SQLX](https://github.com/jmoiron/sqlx) for extra sanity.
|
||||||
- [ ] Write docs for all CLI commands / args AFTER completion.
|
- [ ] Write docs for all CLI commands / args AFTER completion.
|
||||||
- [ ] Finish all the things below:
|
- [ ] Finish all the things below:
|
||||||
|
|
||||||
|
# Protocol Changes?
|
||||||
|
|
||||||
- [ ] Rename `lipmaa` to `backlink` as Bamboo protocol has done?
|
- [ ] Rename `lipmaa` to `backlink` as Bamboo protocol has done?
|
||||||
|
- [ ] Don't enforce a structure on how blobs are packed into bundles- the client is forced to determine the SHA checksum regardless. Forced structure just complicates protocol design.
|
||||||
|
- [ ] Mandate usage of ZIP files so that bundles are always a single file?
|
||||||
|
|
||||||
|Done?|Noun |Verb | Flag / arg 1 | Flag 2 |
|
|Done?|Noun |Verb | Flag / arg 1 | Flag 2 |
|
||||||
|-----|------------|-----------|---------------|-----------|
|
|-----|------------|-----------|---------------|-----------|
|
||||||
| |bundle |ingest | | |
|
| |bundle |ingest | | |
|
||||||
| |blob |remove | mhash | |
|
|
||||||
| |message |show | message mhash | |
|
| |message |show | message mhash | |
|
||||||
| |message |find | --all | |
|
| |message |find | --all | |
|
||||||
|
| |blob |remove | mhash | |
|
||||||
| |message |find | --last | |
|
| |message |find | --last | |
|
||||||
| |draft |create | | |
|
| |draft |create | | |
|
||||||
| |draft |publish | | |
|
| |draft |publish | | |
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 708 B |
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
|
@ -0,0 +1,29 @@
|
||||||
|
author USER.09XBQDDGZPEKFBFBY67XNR5QA0TRWAKYKYNEDNQTZJV0F1JB0DGG
|
||||||
|
depth 0
|
||||||
|
kind example
|
||||||
|
lipmaa NONE
|
||||||
|
prev NONE
|
||||||
|
|
||||||
|
file_name:FILE.FV0FJ0YZADY7C5JTTFYPKDBHTZJ5JVVP5TCKP0605WWXYJG4VMRG
|
||||||
|
|
||||||
|
signature ZYSCKNFP8TW9DME9P9DK4Z4RV09APVEE762HK628K18NMS4DX084XKED71TCRXJNZBWY3TWDYVK1W3K496QF7Y55SCKEWP1D0SP5R30
|
||||||
|
|
||||||
|
author USER.09XBQDDGZPEKFBFBY67XNR5QA0TRWAKYKYNEDNQTZJV0F1JB0DGG
|
||||||
|
depth 1
|
||||||
|
kind example
|
||||||
|
lipmaa NONE
|
||||||
|
prev TEXT.RGKRHC0APNN9FCJTVBN1NR1ZYQ9ZY34PYYASSMJ6016S30ZTWHR0
|
||||||
|
|
||||||
|
file_name:FILE.YPF11E5N9JFVB6KB1N1WDVVT9DXMCHE0XJWBZHT2CQ29S5SEPCSG
|
||||||
|
|
||||||
|
signature GAZGWG8PWZSP4VSSNYD8J873CQ6KDM93SBMA9VGGC1YW66FER96HEGZQ4CJBH51YN22WMGYADNY2SCWS0JY6YPX4APFDQ60X751JJ1R
|
||||||
|
|
||||||
|
author USER.09XBQDDGZPEKFBFBY67XNR5QA0TRWAKYKYNEDNQTZJV0F1JB0DGG
|
||||||
|
depth 2
|
||||||
|
kind example
|
||||||
|
lipmaa NONE
|
||||||
|
prev TEXT.Z3QS1HPX756E22XWKXAXH7NTSTJGY0AHEM9KQNATTC6HHCACZGN0
|
||||||
|
|
||||||
|
file_name:FILE.622PRNJ7C0S05XR2AHDPKWMG051B1QW5SXMN2RQHF2AND6J8VGPG
|
||||||
|
|
||||||
|
signature W94BVC4ED00Z4TJC0T3BEVC63RJYJC1J4DDS13BJTTGGXK40JSX276B9MV3GPS5JJHZW92YKAZNZ1Q4DCG0K58SCD9ZD0TVZVX7100G
|
|
@ -145,6 +145,21 @@ var blobFindCommand = &cobra.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bundleCommand = &cobra.Command{
|
||||||
|
Use: "bundle",
|
||||||
|
Short: "Operations relating to 'bundles'- a package of information provided by peers",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var bundleIngestCommand = &cobra.Command{
|
||||||
|
Use: "ingest",
|
||||||
|
Short: "consume a bundle into the local database",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
panic("Work in progress.")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// BootstrapCLI wires up all the relevant commands.
|
// BootstrapCLI wires up all the relevant commands.
|
||||||
func BootstrapCLI() {
|
func BootstrapCLI() {
|
||||||
rootCmd.AddCommand(versionCmd)
|
rootCmd.AddCommand(versionCmd)
|
||||||
|
@ -163,6 +178,9 @@ func BootstrapCLI() {
|
||||||
blobRootCmd.AddCommand(blobAddCommand)
|
blobRootCmd.AddCommand(blobAddCommand)
|
||||||
blobRootCmd.AddCommand(blobFindCommand)
|
blobRootCmd.AddCommand(blobFindCommand)
|
||||||
|
|
||||||
|
rootCmd.AddCommand(bundleCommand)
|
||||||
|
bundleCommand.AddCommand(bundleIngestCommand)
|
||||||
|
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
func importBundle(path string) error {
|
||||||
|
// Get messages.pgn file
|
||||||
|
// Parse messages
|
||||||
|
// Map over messages
|
||||||
|
return errors.New("Not done yet")
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestImportBundle(t *testing.T) {
|
||||||
|
error := importBundle("../fixtures/has_blobs/messages.pgn")
|
||||||
|
if error != nil {
|
||||||
|
t.Fatalf("Error while importing: %s", error)
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParser(t *testing.T) {
|
func TestParser(t *testing.T) {
|
||||||
content, err1 := ioutil.ReadFile("../fixture.pgn")
|
content, err1 := ioutil.ReadFile("../fixtures/fixture.pgn")
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Fatal(err1)
|
log.Fatal(err1)
|
||||||
}
|
}
|
||||||
|
@ -23,3 +23,33 @@ func TestParser(t *testing.T) {
|
||||||
t.Fatalf("Expected %d items, got %d", fixtureSize, length)
|
t.Fatalf("Expected %d items, got %d", fixtureSize, length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParser2(t *testing.T) {
|
||||||
|
content, err1 := ioutil.ReadFile("../fixtures/has_blobs/messages.pgn")
|
||||||
|
if err1 != nil {
|
||||||
|
log.Fatal(err1)
|
||||||
|
}
|
||||||
|
output, err2 := parseMessage(string(content))
|
||||||
|
|
||||||
|
if err2 != nil {
|
||||||
|
log.Fatal(err2)
|
||||||
|
}
|
||||||
|
|
||||||
|
fixtureSize := 3
|
||||||
|
length := len(output)
|
||||||
|
if length != fixtureSize {
|
||||||
|
t.Fatalf("Expected %d items, got %d", fixtureSize, length)
|
||||||
|
}
|
||||||
|
sig0 := "ZYSCKNFP8TW9DME9P9DK4Z4RV09APVEE762HK628K18NMS4DX084XKED71TCRXJNZBWY3TWDYVK1W3K496QF7Y55SCKEWP1D0SP5R30"
|
||||||
|
if output[0].signature != sig0 {
|
||||||
|
t.Fatal("`sig0` is not correct")
|
||||||
|
}
|
||||||
|
sig1 := "GAZGWG8PWZSP4VSSNYD8J873CQ6KDM93SBMA9VGGC1YW66FER96HEGZQ4CJBH51YN22WMGYADNY2SCWS0JY6YPX4APFDQ60X751JJ1R"
|
||||||
|
if output[1].signature != sig1 {
|
||||||
|
t.Fatal("`sig1` is not correct")
|
||||||
|
}
|
||||||
|
sig2 := "W94BVC4ED00Z4TJC0T3BEVC63RJYJC1J4DDS13BJTTGGXK40JSX276B9MV3GPS5JJHZW92YKAZNZ1Q4DCG0K58SCD9ZD0TVZVX7100G"
|
||||||
|
if output[2].signature != sig2 {
|
||||||
|
t.Fatal("`sig2` is not correct")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue