From 454820f6d692697d5d8faef1ff4b7a7ccb3f6658 Mon Sep 17 00:00:00 2001 From: risotto Date: Mon, 7 Apr 2025 03:20:36 -0600 Subject: [PATCH] add plain test --- file_test.go | 25 ++++++++++++++++++++++++- types/carrier.go | 5 +++++ types/phish.go | 14 ++++++++++++++ types/potential.go | 4 ++++ types/venue.go | 5 +++++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 types/carrier.go create mode 100644 types/phish.go create mode 100644 types/potential.go create mode 100644 types/venue.go diff --git a/file_test.go b/file_test.go index 806b004..842deca 100644 --- a/file_test.go +++ b/file_test.go @@ -7,7 +7,7 @@ import ( "git.bivouac.wiki/go/bloat" ) -func TestFile(t *testing.T) { +func TestEncFile(t *testing.T) { type txttype struct { Abc int Test bool @@ -30,3 +30,26 @@ func TestFile(t *testing.T) { } } +func TestPlainFile(t *testing.T) { + type txttype struct { + Abc int + Test bool + } + recip, err := bloat.NewPlainBloat[txttype]() + sender, err := bloat.NewPlainBloat[txttype]() + plaindata := txttype{Abc: 100, Test: true} + data, err := sender.WritePlain(plaindata, recip) + err = os.WriteFile("test/plain.txttype.bloat", data, 0664) + if err != nil { + t.Errorf("writing failed") + } + content, err := os.ReadFile("test/plain.txttype.bloat") + dec, err := recip.ReadPlain(content, sender) + if dec.Test != plaindata.Test { + t.Errorf("not equal") + } + if dec.Abc != plaindata.Abc { + t.Errorf("not equal") + } + +} diff --git a/types/carrier.go b/types/carrier.go new file mode 100644 index 0000000..4fb15d5 --- /dev/null +++ b/types/carrier.go @@ -0,0 +1,5 @@ +package types + +type Carrier struct { + Addr string `xml:"Addr"` +} diff --git a/types/phish.go b/types/phish.go new file mode 100644 index 0000000..d820d80 --- /dev/null +++ b/types/phish.go @@ -0,0 +1,14 @@ +package types + +import ( + "aead.dev/minisign" + "filippo.io/age" +) + +type BloatPhishXML struct { + AgePub age.X25519Recipient + MinisignPub minisign.PublicKey + NS []BloatPhishXML + Venue []Venue + Carrier []Carrier +} diff --git a/types/potential.go b/types/potential.go new file mode 100644 index 0000000..90426c8 --- /dev/null +++ b/types/potential.go @@ -0,0 +1,4 @@ +package types + +type Potential struct { +} diff --git a/types/venue.go b/types/venue.go new file mode 100644 index 0000000..aa18270 --- /dev/null +++ b/types/venue.go @@ -0,0 +1,5 @@ +package types + +type Venue struct { + Addr string `xml:"Addr"` +}