aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2024-03-03 19:49:31 +0100
committeraxtloss <axtlos@getcryst.al>2024-03-03 19:49:31 +0100
commit5572670ee868f43a2abba5e0de882bd905f1df0a (patch)
treed8f7a87985d0f06ab93a4f22c428f0023aaa25c3
parentb988331159a0fb1a552231e133a2c192713de7c3 (diff)
downloadfsverify-5572670ee868f43a2abba5e0de882bd905f1df0a.tar.gz
fsverify-5572670ee868f43a2abba5e0de882bd905f1df0a.tar.bz2
Add basic test units
Diffstat (limited to '')
-rw-r--r--verify/core/crypt_test.go21
-rw-r--r--verify/core/storage_test.go22
-rw-r--r--verifysetup/core/crypt_test.go12
3 files changed, 55 insertions, 0 deletions
diff --git a/verify/core/crypt_test.go b/verify/core/crypt_test.go
new file mode 100644
index 0000000..5ea42d6
--- /dev/null
+++ b/verify/core/crypt_test.go
@@ -0,0 +1,21 @@
+package core
+
+import "testing"
+
+func TestCalculateStringHash(t *testing.T) {
+ got, err := calculateStringHash("hello")
+ want := "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
+
+ if got != want || err != nil {
+ t.Errorf("got %s, wanted %s", got, want)
+ }
+}
+
+func TestCalculateBlockHash(t *testing.T) {
+ got, err := CalculateBlockHash([]byte("hello"))
+ want := "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
+
+ if got != want || err != nil {
+ t.Errorf("got %s, wanted %s", got, want)
+ }
+}
diff --git a/verify/core/storage_test.go b/verify/core/storage_test.go
new file mode 100644
index 0000000..65cc87c
--- /dev/null
+++ b/verify/core/storage_test.go
@@ -0,0 +1,22 @@
+package core
+
+import "testing"
+
+func TestGethash(t *testing.T) {
+ node := Node{BlockStart: 0, BlockEnd: 0, BlockSum: "AA", PrevNodeSum: "hello"}
+ got, err := node.GetHash()
+ want := "87cdc950224b3850667c0f6a907a5c0dcf047425"
+
+ if got != want || err != nil {
+ t.Errorf("got %s, wanted %s", got, want)
+ }
+}
+
+func TestParseUnitSpec(t *testing.T) {
+ got := parseUnitSpec([]byte{0x0})
+ want := 1
+
+ if got != want {
+ t.Errorf("got %d, wanted %d", got, want)
+ }
+}
diff --git a/verifysetup/core/crypt_test.go b/verifysetup/core/crypt_test.go
new file mode 100644
index 0000000..7a66056
--- /dev/null
+++ b/verifysetup/core/crypt_test.go
@@ -0,0 +1,12 @@
+package core
+
+import "testing"
+
+func TestCalculateBlockHash(t *testing.T) {
+ got, err := CalculateBlockHash([]byte("hello"))
+ want := "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
+
+ if got != want || err != nil {
+ t.Errorf("got %s, wanted %s", got, want)
+ }
+}