def test_create_from_random(self, password_1, password_2): self.interface.confirm_password.side_effect = [password_1, password_2, b'pw3'] self.interface.get_password.side_effect = [password_1, password_2, b'pw3'] self.interface.get_name_for_shard.side_effect = ['one', 'two', 'three'] self.interface.choose_shard.side_effect = ['one', 'two', 'three', None] self.interface.enter_group_information.return_value = [1,[(3,3)]] shard_set = ShardSet(self.interface) shard_set._shards_loaded = True shard_set.create_random_share() result_words = shard_set.wallet_words() assert len(result_words.split(' ')) == 24 assert self.interface.confirm_password.call_count == 3 assert self.interface.get_password.call_count == 3 get_password_calls = [ call(shard.to_str()) for shard in shard_set.shards.values()] assert self.interface.get_password.call_args_list == get_password_calls assert self.interface.get_name_for_shard.call_count == 3 shareid = shard_set.shards['one'].share_id # group index 0, group threshold 1, groups 1, memberid changes, member threshold 2 get_name_calls = [ call(shareid,0,1,1,i,3, shard_set.shards) for i in range(3) ] assert self.interface.get_name_for_shard.call_args_list == get_name_calls assert self.interface.choose_shard.call_count == 3 assert self.interface.enter_group_information.call_count == 1 assert self.rg.random.call_args_list == [call(32), call(2), call(32), call(28)]
def test_create_from_wallet_words(self, zero_wallet_words, password_1, password_2): self.interface.enter_wallet_words.return_value = zero_wallet_words self.interface.confirm_password.side_effect = [password_1, password_2] self.interface.get_password.side_effect = [password_1, password_2] self.interface.get_name_for_shard.side_effect = ['one', 'two'] self.interface.choose_shard.side_effect = ['one', 'two'] self.interface.enter_group_information.return_value = [1,[(2,2)]] shard_set = ShardSet(self.interface) shard_set._shards_loaded = True shard_set.create_share_from_wallet_words() result_words = shard_set.wallet_words() assert result_words == zero_wallet_words assert self.interface.enter_wallet_words.call_count == 1 assert self.interface.confirm_password.call_count == 2 assert self.interface.get_password.call_count == 2 get_password_calls = [ call(shard.to_str()) for shard in shard_set.shards.values()] assert self.interface.get_password.call_args_list == get_password_calls assert self.interface.get_name_for_shard.call_count == 2 shareid = shard_set.shards['one'].share_id # group index 0, group threshold 1, groups 1, memberid changes, member threshold 2 get_name_calls = [ call(shareid,0,1,1,i,2,shard_set.shards) for i in range(2) ] assert self.interface.get_name_for_shard.call_args_list == get_name_calls assert self.interface.choose_shard.call_count == 2 assert self.interface.enter_group_information.call_count == 1 assert self.rg.random.call_args_list == [call(2), call(28)]