github.com/condensat/bank-core@v0.1.0/database/model/ssmaddress_test.go (about) 1 // Copyright 2020 Condensat Tech. All rights reserved. 2 // Use of this source code is governed by a MIT 3 // license that can be found in the LICENSE file. 4 5 package model 6 7 import "testing" 8 9 func TestSsmAddress_Valid(t *testing.T) { 10 type fields struct { 11 ID SsmAddressID 12 PublicAddress SsmPublicAddress 13 ScriptPubkey SsmPubkey 14 BlindingKey SsmBlindingKey 15 } 16 tests := []struct { 17 name string 18 fields fields 19 want bool 20 }{ 21 {"Default", fields{}, false}, 22 {"InvalidPublicAddress", fields{0, "", "bar", ""}, false}, 23 {"InvalidScriptPubkey", fields{0, "foo", "", ""}, false}, 24 {"InvalidWithOptional", fields{0, "", "", "foobar"}, false}, 25 {"InvalidPublicAddressOptional", fields{0, "", "bar", "foobar"}, false}, 26 {"InvalidScriptPubkeyOptional", fields{0, "foo", "", "foobar"}, false}, 27 28 {"Valid", fields{0, "foo", "bar", ""}, true}, 29 {"Optional", fields{0, "foo", "bar", "foobar"}, true}, 30 } 31 for _, tt := range tests { 32 t.Run(tt.name, func(t *testing.T) { 33 p := &SsmAddress{ 34 ID: tt.fields.ID, 35 PublicAddress: tt.fields.PublicAddress, 36 ScriptPubkey: tt.fields.ScriptPubkey, 37 BlindingKey: tt.fields.BlindingKey, 38 } 39 if got := p.IsValid(); got != tt.want { 40 t.Errorf("SsmAddress.IsValid() = %v, want %v", got, tt.want) 41 } 42 }) 43 } 44 }