Пример #1
0
    def test_su_update_participants_votes(self):
        """
        Test that the support edges with the new amount of tokens the
        Participant has staked on the Proposal are being updated.
        """
        network_copy = copy.copy(self.network)
        _input = {"participants_stake_on_proposals": {0: {4: 500.0, 5: 400.0}}}
        ParticipantVoting.su_update_participants_votes(self.params, 0, 0, {
            "network": network_copy,
            "funding_pool": 1000,
            "token_supply": 1000
        }, _input)

        self.assertEqual(network_copy[0][4]["support"].tokens, 500)
        self.assertEqual(network_copy[0][5]["support"].tokens, 400)
Пример #2
0
    def test_p_participant_votes_on_proposal_according_to_affinity(self):
        """
        Ensure that when a Participant votes on 2 Proposals of equal affinity,
        he will split his tokens 50-50 between them.
        """
        with patch("entities.probability") as p:
            p.return_value = True
            ans = ParticipantVoting.p_participant_votes_on_proposal_according_to_affinity(
                self.params, 0, 0, {
                    "network": copy.copy(self.network),
                    "funding_pool": 1000,
                    "token_supply": 1000
                })

            reference = {
                'participants_stake_on_proposals': {
                    0: {
                        4: 500.0,
                        5: 500.0
                    },
                    1: {
                        4: 500.0,
                        5: 500.0
                    },
                    2: {
                        4: 500.0,
                        5: 500.0
                    },
                    3: {
                        4: 500.0,
                        5: 500.0
                    }
                }
            }
            self.assertEqual(ans, reference)
Пример #3
0
    def test_p_participant_votes_on_proposal_according_to_affinity_vesting_nonvesting(
            self):
        """
        Ensure that when a Participant with vesting and nonvesting tokens votes
        on 2 Proposals of equal affinity, all of his tokens will be split 50-50
        between them.
        """
        participants = get_participants(self.network)
        for _, participant in participants:
            participant.holdings = TokenBatch(1000, 1000)

        with patch("entities.probability") as p:
            p.return_value = True
            ans = ParticipantVoting.p_participant_votes_on_proposal_according_to_affinity(
                self.params, 0, 0, {
                    "network": copy.copy(self.network),
                    "funding_pool": 1000,
                    "token_supply": 1000
                })

            reference = {
                'participants_stake_on_proposals': {
                    0: {
                        4: 1000.0,
                        5: 1000.0
                    },
                    1: {
                        4: 1000.0,
                        5: 1000.0
                    },
                    2: {
                        4: 1000.0,
                        5: 1000.0
                    },
                    3: {
                        4: 1000.0,
                        5: 1000.0
                    }
                }
            }
            self.assertEqual(ans, reference)