Commit 3a1cc6db authored by mdj33's avatar mdj33 Committed by vipwzw

add ut

parent 480b8a3a
......@@ -111,6 +111,7 @@ func (a *action) configTransfer(config *coinTy.TransferFlagConfig) (*types.Recei
}
//过滤重复地址
func filterAddrs(addrs []string) []string {
f := make(map[string]bool)
var newAddrs []string
......@@ -143,6 +144,7 @@ func (a *action) addAccounts(addrs []string) (*types.Receipt, error) {
}
//删除掉指定地址
func filterByAddrs(curr, del []string) []string {
f := make(map[string]bool)
for _, k := range del {
......
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestFilterByAddrs(t *testing.T) {
curr := []string{"aa", "bb", "cc"}
del := []string{"bb"}
expect := []string{"aa", "cc"}
ret := filterByAddrs(curr, del)
assert.Equal(t, ret, expect)
del = []string{"aa", "bb", "cc"}
ret = filterByAddrs(curr, del)
assert.Equal(t, []string(nil), ret)
}
func TestFilterAddrs(t *testing.T) {
curr := []string{"aa", "bb", "cc", "bb"}
exp := []string{"aa", "bb", "cc"}
ret := filterAddrs(curr)
assert.Equal(t, ret, exp)
curr = []string{"bb", "bb"}
ret = filterAddrs(curr)
assert.Equal(t, []string{"bb"}, ret)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment