github.com/condensat/bank-core@v0.1.0/database/model/cryptoaddress_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 (
     8  	"testing"
     9  )
    10  
    11  func TestCryptoAddress_IsUsed(t *testing.T) {
    12  	t.Parallel()
    13  
    14  	type fields struct {
    15  		FirstBlockId BlockID
    16  	}
    17  	tests := []struct {
    18  		name   string
    19  		fields fields
    20  		want   bool
    21  	}{
    22  		{"default", fields{}, false},
    23  		{"mempool", fields{BlockID(1)}, true},
    24  		{"mined", fields{BlockID(424242)}, true},
    25  	}
    26  	for _, tt := range tests {
    27  		tt := tt // capture range variable
    28  		t.Run(tt.name, func(t *testing.T) {
    29  			p := &CryptoAddress{
    30  				FirstBlockId: tt.fields.FirstBlockId,
    31  			}
    32  			if got := p.IsUsed(); got != tt.want {
    33  				t.Errorf("CryptoAddress.IsUsed() = %v, want %v", got, tt.want)
    34  			}
    35  		})
    36  	}
    37  }
    38  
    39  func TestCryptoAddress_Confirmations(t *testing.T) {
    40  	t.Parallel()
    41  
    42  	type fields struct {
    43  		FirstBlockId BlockID
    44  	}
    45  	type args struct {
    46  		height BlockID
    47  	}
    48  	tests := []struct {
    49  		name   string
    50  		fields fields
    51  		args   args
    52  		want   int
    53  	}{
    54  		{"default", fields{}, args{}, 0},
    55  		{"mempool", fields{BlockID(1)}, args{424242}, 0},
    56  		{"mined", fields{BlockID(424242)}, args{424242}, int(MemPoolBlockID)},
    57  		{"confirmed", fields{BlockID(424242)}, args{424247}, 6},
    58  		{"future", fields{BlockID(424243)}, args{424242}, 0},
    59  	}
    60  	for _, tt := range tests {
    61  		tt := tt // capture range variable
    62  		t.Run(tt.name, func(t *testing.T) {
    63  			p := &CryptoAddress{
    64  				FirstBlockId: tt.fields.FirstBlockId,
    65  			}
    66  			if got := p.Confirmations(tt.args.height); got != tt.want {
    67  				t.Errorf("CryptoAddress.Confirmations() = %v, want %v", got, tt.want)
    68  			}
    69  		})
    70  	}
    71  }