def test_6_change_did_boundary(self):
        # account password match error
        ec, message = mvs_rpc.change_did(Alice.name, Alice.password + '1',
                                         Alice.addresslist[1],
                                         Alice.did_symbol)
        self.assertEqual(ec, 1000, message)

        # Did 'ZAC.DID' does not exist in blockchain
        ec, message = mvs_rpc.change_did(Alice.name, Alice.password,
                                         Alice.addresslist[1], Zac.did_symbol)
        self.assertEqual(ec, 7006, message)

        # Did 'BOB.DID' is not owned by Alice
        ec, message = mvs_rpc.change_did(Alice.name, Alice.password,
                                         Alice.addresslist[1], Bob.did_symbol)
        self.assertEqual(ec, 7009, message)

        # Target address is not owned by account.
        ec, message = mvs_rpc.change_did(Alice.name, Alice.password,
                                         Bob.addresslist[1], Alice.did_symbol)
        self.assertEqual(ec, 4003, message)

        # Target address is already binded with some did in blockchain
        ec, message = mvs_rpc.change_did(Alice.name, Alice.password,
                                         Alice.mainaddress(), Alice.did_symbol)
        self.assertEqual(ec, 7002, message)
    def test_7_change_did(self):
        '''modify did between Zac's addresses'''
        temp_did = "ZAC.DIID@" + common.get_timestamp()
        Alice.send_etp(Zac.mainaddress(), 10**8)
        Alice.mining()
        ec, message = mvs_rpc.register_did(Zac.name, Zac.password,
                                           Zac.mainaddress(), temp_did)
        self.assertEqual(ec, 0, message)
        Alice.mining()

        # no enough balance, unspent = 0, payment = 10000
        ec, message = mvs_rpc.change_did(Zac.name, Zac.password,
                                         Zac.addresslist[1], temp_did)
        self.assertEqual(ec, 3302, message)

        Alice.send_etp(Zac.addresslist[1], 10**4)
        Alice.mining()

        ec, message = mvs_rpc.change_did(Zac.name, Zac.password,
                                         Zac.addresslist[1], temp_did)
        self.assertEqual(ec, 0, message)
        Alice.mining()

        ec, message = mvs_rpc.list_dids(Zac.name, Zac.password)
        self.assertEqual(ec, 0, message)

        self.assertEqual(message['dids'][0]['symbol'], temp_did, message)
        self.assertEqual(message['dids'][0]['address'], Zac.addresslist[1],
                         message)

        # confirm the modification procedure by list_didaddresses
        ec, message = mvs_rpc.list_didaddresses(temp_did)
        self.assertEqual(ec, 0, message)

        self.assertEqual(message['addresses'][0]["address"],
                         Zac.addresslist[1])
        self.assertEqual(message['addresses'][0]["status"], "current")

        self.assertEqual(message['addresses'][1]["address"],
                         Zac.addresslist[0])
        self.assertEqual(message['addresses'][1]["status"], "history")
    def test_9_change_did_multisig(self):
        did_normal_symbal = "Zac@" + common.get_timestamp()
        Alice.send_etp(Zac.mainaddress(), 10**8)
        Alice.mining()

        ec, message = mvs_rpc.register_did(Zac.name, Zac.password,
                                           Zac.mainaddress(),
                                           did_normal_symbal)
        self.assertEqual(ec, 0, message)
        Alice.mining()

        group = [Alice, Cindy, Dale, Frank, Zac]

        did_symbol = '@'.join(r.name for r in group) + common.get_timestamp()
        for i, role in enumerate(group):
            addr = role.new_multisigaddress(
                "Alice & Cindy & Zac's Multisig-DID",
                group[:i] + group[i + 1:], 3)

        Alice.send_etp(addr, (10**9))
        Alice.mining()

        ec, message = mvs_rpc.register_did(group[0].name, group[0].password,
                                           addr, did_symbol)
        self.assertEqual(ec, 0, message)

        ec, message = mvs_rpc.sign_multisigtx(group[1].name, group[1].password,
                                              message)
        self.assertEqual(ec, 0, message)

        ec, message = mvs_rpc.sign_multisigtx(group[2].name, group[2].password,
                                              message, True)
        self.assertEqual(ec, 0, message)
        Alice.mining()

        # did not find
        ec, message = mvs_rpc.change_did(Zac.name, Zac.password,
                                         Zac.mainaddress(),
                                         common.get_timestamp())
        self.assertEqual(ec, 7006, message)

        #did not owner by account
        ec, message = mvs_rpc.change_did(Bob.name, Bob.password,
                                         Bob.mainaddress(), did_symbol)
        self.assertEqual(ec, 7009, message)

        #did address invalid
        ec, message = mvs_rpc.change_did(Zac.name, Zac.password, "Test" * 20,
                                         did_symbol)
        self.assertEqual(ec, 4012, message)

        #address didn't owned by the account
        ec, message = mvs_rpc.change_did(Zac.name, Zac.password,
                                         Bob.mainaddress(), did_symbol)
        self.assertEqual(ec, 4003, message)

        #address is already binded with did
        ec, message = mvs_rpc.change_did(Zac.name, Zac.password,
                                         Zac.mainaddress(), did_symbol)
        self.assertEqual(ec, 7002, message)

        # no enough balance, unspent = 0, payment = 10000
        ec, message = mvs_rpc.change_did(Zac.name, Zac.password,
                                         Zac.addresslist[1], did_symbol)
        self.assertEqual(ec, 3302, message)

        Alice.send_etp(Zac.addresslist[1], 10**5)
        Alice.mining()

        #signature must be large than 3
        ec, message = mvs_rpc.change_did(Zac.name, Zac.password,
                                         Zac.addresslist[1], did_symbol)
        self.assertEqual(ec, 0, message)

        #cannot transfer to another multi-signature
        ec, message = mvs_rpc.sign_multisigtx(group[0].name, group[0].password,
                                              message, True)
        self.assertEqual(ec, 5304, message)

        group_new = [Bob, Dale, Zac]
        for i, role in enumerate(group_new):
            addr_new = role.new_multisigaddress(
                "Bob & Dale & Zac's Multisig-DID",
                group_new[:i] + group_new[i + 1:], 2)

        Alice.send_etp(addr_new, (10**6))
        Alice.mining()
        ec, message = mvs_rpc.change_did(Zac.name, Zac.password, addr_new,
                                         did_symbol)
        self.assertEqual(ec, 7010, message)

        ec, message = mvs_rpc.change_did(Zac.name, Zac.password,
                                         Zac.addresslist[1], did_symbol)
        self.assertEqual(ec, 0, message)

        ec, message = mvs_rpc.sign_multisigtx(group[0].name, group[0].password,
                                              message)
        self.assertEqual(ec, 0, message)

        ec, message = mvs_rpc.sign_multisigtx(group[1].name, group[1].password,
                                              message, True)
        self.assertEqual(ec, 0, message)
        self.assertNotEqual(
            Zac.get_didaddress(symbol=did_symbol), Zac.addresslist[1],
            "Failed where modify did address from multi_signature to multi_signature address"
        )