(t *testing.T)
| 169 | } |
| 170 | |
| 171 | func TestClientSetLabel(t *testing.T) { |
| 172 | accountNum := testWallet.GetAccountNum() |
| 173 | accountSize := 10 |
| 174 | if accountNum < accountSize { |
| 175 | for i := accountSize - accountNum; i > accountNum; i-- { |
| 176 | _, err := testWallet.NewAccount("", keypair.PK_ECDSA, keypair.P256, s.SHA256withECDSA, testPasswd) |
| 177 | if err != nil { |
| 178 | t.Errorf("TestClientSetLabel NewAccount error:%s", err) |
| 179 | return |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | testAccIndex := 5 |
| 184 | testAcc := testWallet.GetAccountMetadataByIndex(testAccIndex) |
| 185 | oldLabel := testAcc.Label |
| 186 | newLabel := fmt.Sprintf("%s-%d", oldLabel, testAccIndex) |
| 187 | |
| 188 | accountNum = testWallet.GetAccountNum() |
| 189 | err := testWallet.SetLabel(testAcc.Address, newLabel) |
| 190 | if err != nil { |
| 191 | t.Errorf("TestClientSetLabel SetLabel error:%s", err) |
| 192 | return |
| 193 | } |
| 194 | |
| 195 | if testWallet.GetAccountNum() != accountNum { |
| 196 | t.Errorf("TestClientSetLabel account num %d != %d", testWallet.GetAccountNum(), accountNum) |
| 197 | return |
| 198 | } |
| 199 | |
| 200 | accTmp, err := testWallet.GetAccountByLabel(newLabel, testPasswd) |
| 201 | if err != nil { |
| 202 | t.Errorf("TestClientSetLabel GetAccountByLabel:%s error:%s", newLabel, err) |
| 203 | return |
| 204 | } |
| 205 | if accTmp == nil { |
| 206 | t.Errorf("TestClientSetLabel cannot get account by label:%s", newLabel) |
| 207 | return |
| 208 | } |
| 209 | |
| 210 | if accTmp.Address.ToBase58() != testAcc.Address { |
| 211 | t.Errorf("TestClientSetLabel address:%s != %s", accTmp.Address.ToBase58(), testAcc.Address) |
| 212 | return |
| 213 | } |
| 214 | |
| 215 | accTmp, err = testWallet.GetAccountByLabel(oldLabel, testPasswd) |
| 216 | if err != nil { |
| 217 | t.Errorf("TestClientSetLabel GetAccountByLabel:%s error:%s", oldLabel, err) |
| 218 | return |
| 219 | } |
| 220 | if accTmp != nil { |
| 221 | t.Errorf("TestClientSetLabel GetAccountByLabel:%s should return nil", oldLabel) |
| 222 | return |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | func TestClientSetDefault(t *testing.T) { |
| 227 | accountNum := testWallet.GetAccountNum() |
nothing calls this directly
no test coverage detected