diff --git a/daemon/wallet_rpc_test.go b/daemon/wallet_rpc_test.go new file mode 100644 index 0000000..6c55669 --- /dev/null +++ b/daemon/wallet_rpc_test.go @@ -0,0 +1,31 @@ +package daemon + +import "testing" + +func TestWalletProxy_IsWalletMethod_Good(t *testing.T) { + walletMethods := []string{"getbalance", "getaddress", "transfer", "deploy_asset", "register_alias"} + for _, m := range walletMethods { + if !IsWalletMethod(m) { + t.Errorf("%s should be a wallet method", m) + } + } +} + +func TestWalletProxy_IsWalletMethod_Bad(t *testing.T) { + chainMethods := []string{"getinfo", "getheight", "get_all_alias_details", "search"} + for _, m := range chainMethods { + if IsWalletMethod(m) { + t.Errorf("%s should NOT be a wallet method", m) + } + } +} + +func TestWalletProxy_New_Good(t *testing.T) { + proxy := NewWalletProxy("http://127.0.0.1:46944") + if proxy == nil { + t.Fatal("proxy is nil") + } + if proxy.walletURL != "http://127.0.0.1:46944" { + t.Errorf("url: %s", proxy.walletURL) + } +} diff --git a/wallet/chain_scanner_test.go b/wallet/chain_scanner_test.go new file mode 100644 index 0000000..a33230a --- /dev/null +++ b/wallet/chain_scanner_test.go @@ -0,0 +1,33 @@ +package wallet + +import ( + "testing" + + "dappco.re/go/core/blockchain/types" +) + +func TestChainScanner_New_Good(t *testing.T) { + account, _ := GenerateAccount() + getter := func(h uint64) (*types.Block, []types.Transaction, error) { + return nil, nil, nil + } + scanner := NewChainScanner(account, getter) + if scanner == nil { + t.Fatal("scanner is nil") + } +} + +func TestChainScanner_ScanRange_Empty_Good(t *testing.T) { + account, _ := GenerateAccount() + getter := func(h uint64) (*types.Block, []types.Transaction, error) { + return nil, nil, nil + } + scanner := NewChainScanner(account, getter) + transfers, scanned := scanner.ScanRange(0, 10) + if len(transfers) != 0 { + t.Errorf("expected 0 transfers, got %d", len(transfers)) + } + if scanned != 0 { + t.Errorf("expected 0 scanned (nil blocks), got %d", scanned) + } +}