From 8694f147d577acb94cebae5967baa0d38a3fab45 Mon Sep 17 00:00:00 2001 From: ffranr Date: Mon, 23 Jan 2023 17:59:31 +0000 Subject: [PATCH] unit tests: remove use of onion type V2 We only support tor V3. --- onion_store_test.go | 46 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/onion_store_test.go b/onion_store_test.go index b76780d..4d26c34 100644 --- a/onion_store_test.go +++ b/onion_store_test.go @@ -11,12 +11,12 @@ import ( // onion service exists in the store. If it does, it's compared against what's // expected. func assertPrivateKeyExists(t *testing.T, store *onionStore, - onionType tor.OnionType, expPrivateKey *[]byte) { + expPrivateKey *[]byte) { t.Helper() exists := expPrivateKey != nil - privateKey, err := store.PrivateKey(onionType) + privateKey, err := store.PrivateKey() switch { case exists && err != nil: t.Fatalf("unable to retrieve private key: %v", err) @@ -32,8 +32,8 @@ func assertPrivateKeyExists(t *testing.T, store *onionStore, } } -// TestOnionStore ensures the different operations of the onionStore behave as -// espected. +// TestOnionStore ensures the different operations of the onionStore behave +// as expected. func TestOnionStore(t *testing.T) { etcdClient, serverCleanup := etcdSetup(t) defer etcdClient.Close() @@ -42,40 +42,22 @@ func TestOnionStore(t *testing.T) { // Upon a fresh initialization of the store, no private keys should // exist for any onion service type. store := newOnionStore(etcdClient) - assertPrivateKeyExists(t, store, tor.V2, nil) - assertPrivateKeyExists(t, store, tor.V3, nil) + assertPrivateKeyExists(t, store, nil) - // Store a private key for a V2 onion service and check it was stored + // Store a private key for an onion service and check it was stored // correctly. - privateKeyV2 := []byte("hide_me_plz_v2") - if err := store.StorePrivateKey(tor.V2, privateKeyV2); err != nil { - t.Fatalf("unable to store private key for v2 onion service: %v", + privateKey := []byte("hide_me_plz") + if err := store.StorePrivateKey(privateKey); err != nil { + t.Fatalf("unable to store private key for onion service: %v", err) } - assertPrivateKeyExists(t, store, tor.V2, &privateKeyV2) + assertPrivateKeyExists(t, store, &privateKey) - // Store a private key for a V3 onion service and check it was stored - // correctly. - privateKeyV3 := []byte("hide_me_plz_v3") - if err := store.StorePrivateKey(tor.V3, privateKeyV3); err != nil { - t.Fatalf("unable to store private key for v3 onion service: %v", - err) - } - assertPrivateKeyExists(t, store, tor.V3, &privateKeyV3) - - // Delete the private key for the V2 onion service and check that it was + // Delete the private key for the onion service and check that it was // indeed successful. - if err := store.DeletePrivateKey(tor.V2); err != nil { - t.Fatalf("unable to remove private key for v2 onion service: %v", + if err := store.DeletePrivateKey(); err != nil { + t.Fatalf("unable to remove private key for onion service: %v", err) } - assertPrivateKeyExists(t, store, tor.V2, nil) - - // Delete the private key for the V3 onion service and check that it was - // indeed successful. - if err := store.DeletePrivateKey(tor.V3); err != nil { - t.Fatalf("unable to remove private key for v3 onion service: %v", - err) - } - assertPrivateKeyExists(t, store, tor.V3, nil) + assertPrivateKeyExists(t, store, nil) }