Exemplo n.º 1
0
    def test_su_buy_participants_tokens(self):
        policy_result = {
            'participant_decisions': {
                0: 1000.0,
                1: 1000.0,
                2: 1000.0,
                3: 1000.0
            },
            'total_dai': 4000.0,
            'tokens': 1449.489742783178,
            'token_price': 2.7595917942265427,
            "final_token_distribution": {
                0: 0.25,
                1: 0.25,
                2: 0.25,
                3: 0.25
            }
        }
        old_token_supply = self.commons._token_supply
        old_funding_pool = self.commons._funding_pool

        _, commons = ParticipantBuysTokens.su_buy_participants_tokens(
            self.params, 0, 0, self.default_state, policy_result)

        self.assertEqual(commons._token_supply, 2449.489742783178)
        self.assertEqual(commons._funding_pool, old_funding_pool)  # 200
Exemplo n.º 2
0
 def test_p_decide_to_buy_tokens_bulk(self):
     with patch("entities.Participant.buy") as p:
         p.return_value = 1000.0
         a = ParticipantBuysTokens.p_decide_to_buy_tokens_bulk(
             self.params, 0, 0, self.default_state)
         decisions = a["participant_decisions"]
         final_token_distribution = a["final_token_distribution"]
         for participant_idx, decision in decisions.items():
             self.assertNotEqual(decision, 0)
             self.assertEqual(final_token_distribution[participant_idx],
                              0.25)
Exemplo n.º 3
0
    def test_p_decide_to_buy_tokens_bulk_no_tokens_bought(self):
        with patch("entities.Participant.buy") as p:
            p.return_value = 0.0
            a = ParticipantBuysTokens.p_decide_to_buy_tokens_bulk(
                self.params, 0, 0, self.default_state)

            expected = {
                "participant_decisions": {},
                "total_dai": 0,
                "tokens": 0,
                "token_price": 0,
                "final_token_distribution": {}
            }
            self.assertEqual(expected, a)
Exemplo n.º 4
0
    def test_su_buy_participants_tokens_zero(self):
        policy_result = {
            'participant_decisions': {},
            'total_dai': 0.0,
            'tokens': 0,
            'token_price': 0,
            "final_token_distribution": {}
        }
        old_token_supply = self.commons._token_supply
        old_funding_pool = self.commons._funding_pool

        _, commons = ParticipantBuysTokens.su_buy_participants_tokens(
            self.params, 0, 0, self.default_state, policy_result)

        self.assertEqual(commons._token_supply, old_token_supply)
        self.assertEqual(commons._funding_pool, old_funding_pool)
Exemplo n.º 5
0
    def test_su_update_participants_tokens(self):
        policy_result = {
            'participant_decisions': {
                0: 1000.0,
                1: 1000.0,
                2: 1000.0,
                3: 1000.0
            },
            'total_dai': 4000.0,
            'tokens': 1449.489742783178,
            'token_price': 2.7595917942265427,
            "final_token_distribution": {
                0: 0.25,
                1: 0.25,
                2: 0.25,
                3: 0.25
            }
        }
        _, network = ParticipantBuysTokens.su_update_participants_tokens(
            self.params, 0, 0, self.default_state, policy_result)

        for i in [0, 1, 2, 3]:
            self.assertEqual(network.nodes[i]["item"].holdings.nonvesting,
                             1362.3724356957946)