Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Public Member Functions | List of all members
test.test_server_state.TestServerState Class Reference
Inheritance diagram for test.test_server_state.TestServerState:
Inheritance graph
[legend]
Collaboration diagram for test.test_server_state.TestServerState:
Collaboration graph
[legend]

Public Member Functions

None test_configuration (self)
 
None test_state_serialization (self)
 

Detailed Description

Definition at line 71 of file test_server_state.py.

Member Function Documentation

◆ test_configuration()

None test.test_server_state.TestServerState.test_configuration (   self)

Definition at line 73 of file test_server_state.py.

73  def test_configuration(self) -> None:
74  config_1 = self._dummy_config()
75  config_json_1 = config_1.to_json()
76  config_2 = Configuration.from_json(config_json_1)
77  config_json_2 = config_2.to_json()
78  self.assertEqual(config_json_1, config_json_2)
79 
Here is the call graph for this function:

◆ test_state_serialization()

None test.test_server_state.TestServerState.test_state_serialization (   self)

Definition at line 80 of file test_server_state.py.

80  def test_state_serialization(self) -> None:
81  config = self._dummy_config()
82  contributors = self._dummy_contributors()
83  state = initial_server_state(config, contributors)
84 
85  # initial state
86  self.assertEqual(0, state.next_contributor_index)
87  self.assertEqual(
88  START_TIME + CONTRIBUTION_INTERVAL,
89  state.next_contributor_deadline)
90 
91  # json serialization
92  self._test_json_serialization(state)
93 
94  # update, deadline not passed
95  state.update(
96  START_TIME + (CONTRIBUTION_INTERVAL / 2),
97  CONTRIBUTION_INTERVAL)
98  self.assertEqual(0, state.next_contributor_index)
99  self.assertEqual(
100  START_TIME + CONTRIBUTION_INTERVAL,
101  state.next_contributor_deadline)
102  self.assertFalse(state.have_all_contributions())
103 
104  # json serialization
105  self._test_json_serialization(state)
106 
107  # deadline passed with no contribution
108  state.update(
109  START_TIME + CONTRIBUTION_INTERVAL + 0.1,
110  CONTRIBUTION_INTERVAL)
111  self.assertEqual(1, state.next_contributor_index)
112  self.assertEqual(
113  START_TIME + 0.1 + 2 * CONTRIBUTION_INTERVAL,
114  state.next_contributor_deadline)
115  self.assertFalse(state.have_all_contributions())
116 
117  # json serialization
118  self._test_json_serialization(state)
119 
120  # got contribution part way through interval
121  state.received_contribution(
122  START_TIME + 0.1 + 2.5 * CONTRIBUTION_INTERVAL)
123  self.assertEqual(2, state.next_contributor_index)
124  self.assertEqual(
125  START_TIME + 0.1 + 2.5 * CONTRIBUTION_INTERVAL,
126  state.next_contributor_deadline)
127  self.assertFalse(state.have_all_contributions())
128 
129  # json serialization
130  self._test_json_serialization(state)
131 
132  # 3rd contribution deadline
133  state.update(
134  START_TIME + 0.2 + 2.5 * CONTRIBUTION_INTERVAL,
135  CONTRIBUTION_INTERVAL)
136  self.assertEqual(3, state.next_contributor_index)
137  self.assertEqual(
138  START_TIME + 0.2 + 3.5 * CONTRIBUTION_INTERVAL,
139  state.next_contributor_deadline)
140  self.assertFalse(state.have_all_contributions())
141 
142  # final contribution
143  state.received_contribution(
144  START_TIME + 0.2 + 3.0 * CONTRIBUTION_INTERVAL)
145  self.assertTrue(state.have_all_contributions())
146  self.assertEqual(0, state.next_contributor_deadline)
147 
148  # json serialization
149  self._test_json_serialization(state)
150 
Here is the call graph for this function:

The documentation for this class was generated from the following file:
coordinator.server_state.initial_server_state
ServerState initial_server_state(Configuration configuration, ContributorList contributors)
Definition: server_state.py:86
test.test_server_state.TestServerState.test_state_serialization
None test_state_serialization(self)
Definition: test_server_state.py:80
test.test_server_state.TestServerState.test_configuration
None test_configuration(self)
Definition: test_server_state.py:73