Пример #1
0
    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)]
Пример #2
0
    def test_create_from_random_large_group(self):
        # Make all the passwords the same to make things easier
        self.interface.confirm_password.return_value = b'password'
        self.interface.get_password.return_value = b'password'

        self.interface.get_name_for_shard.side_effect = (str(x)
                                                         for x in range(100))
        self.interface.enter_group_information.return_value = [
            3, [(7, 15), (7, 15), (7, 15), (7, 15)]
        ]

        shard_set = ShardSet(self.interface)
        shard_set._shards_loaded = True

        shard_set.create_random_share()

        assert self.interface.confirm_password.call_count == 15 * 4
        assert self.interface.get_name_for_shard.call_count == 15 * 4
        assert self.interface.enter_group_information.call_count == 1

        calls = (
            [
                call(32),
            ] +  # master secret
            [
                call(2),
            ] +  # identifier
            [call(32), call(28)] +  # group secrets (less digest)
            ([call(32)] * 5 + [call(28)]) * 4  # member secrets (less digests)
        )
        assert self.rg.random.call_args_list == calls