From f20d508fb8912d202eb5ecd5d5ea128358d6f1be Mon Sep 17 00:00:00 2001 From: danwt <30197399+danwt@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:34:46 +0100 Subject: [PATCH 1/2] add fuzz test --- da/da_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/da/da_test.go b/da/da_test.go index 8901abbee..dce8ee686 100644 --- a/da/da_test.go +++ b/da/da_test.go @@ -1,9 +1,11 @@ package da_test import ( + "bytes" cryptoRand "crypto/rand" "encoding/json" "math/rand" //#gosec + "strings" "testing" "time" @@ -250,3 +252,31 @@ func getRandomBytes(n int) []byte { _, _ = cryptoRand.Read(data) return data } + +func FuzzDASubmitMetaData(f *testing.F) { + f.Fuzz(func(t *testing.T, client string, height uint64, index, length int, commitment, namespace, root []byte) { + if client == "" || strings.Contains(client, da.PathSeparator) || len(commitment) == 0 || len(namespace) == 0 || len(root) == 0 { + t.Skip() + } + data := da.DASubmitMetaData{ + Client: da.Client(client), + Height: height, + Index: index, + Length: length, + Commitment: commitment, + Namespace: namespace, + Root: root, + } + + path := data.ToPath() + got, err := data.FromPath(path) + require.NoError(t, err) + require.Equal(t, data.Client, got.Client) + require.Equal(t, data.Height, got.Height) + require.Equal(t, data.Index, got.Index) + require.Equal(t, data.Length, got.Length) + require.True(t, bytes.Equal(data.Commitment, got.Commitment)) + require.True(t, bytes.Equal(data.Namespace, got.Namespace)) + require.True(t, bytes.Equal(data.Root, got.Root)) + }) +} From 7e19ee34e9262166167086b9e61e2bc6b0cd525d Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 28 Apr 2024 18:35:35 +0000 Subject: [PATCH 2/2] Update CHANGELOG.md [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 678a11728..8910906cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Bug Fixes +* **da:** fixed da path seperator and encoding issue ([#731](https://github.com/dymensionxyz/dymint/issues/731)) ([3a3b219](https://github.com/dymensionxyz/dymint/commit/3a3b21932750fee7eaaa9c186f78e36e3e597746)) * **p2p:** validate block before applying and not before caching in p2p gossiping ([#723](https://github.com/dymensionxyz/dymint/issues/723)) ([98371b5](https://github.com/dymensionxyz/dymint/commit/98371b5220613e70f3274fab5593e02ba532f7db)) * **produce loop:** handle unauthenticated error in settlement layer ([#726](https://github.com/dymensionxyz/dymint/issues/726)) ([33e78d1](https://github.com/dymensionxyz/dymint/commit/33e78d116b5f14b91b8b3bda2b6cbfee9040e2d3))