github.com/kisexp/xdchain@v0.0.0-20211206025815-490d6b732aa7/plugin/verifier_test.go (about) 1 package plugin 2 3 import ( 4 "io/ioutil" 5 "os" 6 "path" 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestNewVerifier_whenResolvingDefaultPublicKeyLocation(t *testing.T) { 13 tmpDir, err := ioutil.TempDir("", "q-") 14 if err != nil { 15 t.Fatal(err) 16 } 17 defer func() { 18 _ = os.RemoveAll(tmpDir) 19 }() 20 if err := ioutil.WriteFile(path.Join(tmpDir, DefaultPublicKeyFile), []byte("foo"), 0644); err != nil { 21 t.Fatal(err) 22 } 23 arbitraryPM := &PluginManager{ 24 pluginBaseDir: tmpDir, 25 } 26 27 testObject, err := NewVerifier(arbitraryPM, true, "") 28 29 assert.NoError(t, err) 30 assert.IsType(t, &LocalVerifier{}, testObject) 31 } 32 33 func TestNewVerifier_whenUsingOnlineVerifier(t *testing.T) { 34 arbitraryPM := &PluginManager{} 35 36 testObject, err := NewVerifier(arbitraryPM, false, "") 37 38 assert.NoError(t, err) 39 assert.IsType(t, &OnlineVerifier{}, testObject) 40 }