def test_initializeLedgers_proportional1(): expected = { 0: { 1: Ledger(5, 5), 2: Ledger(5, 5) }, 1: { 0: Ledger(5, 5), 2: Ledger(5, 5) }, 2: { 0: Ledger(5, 5), 1: Ledger(5, 5) }, } actual = initialLedgers('proportional', [10, 10, 10]) assert actual == expected, "proportional ledger generation not as expected (1)"
def test_initializeLedgers_proportional2(): expected = { 0: { 1: Ledger(1.2, 1), 2: Ledger(9, 3) }, 1: { 0: Ledger(1, 1.2), 2: Ledger(27, 10.8) }, 2: { 0: Ledger(3, 9), 1: Ledger(10.8, 27) }, } actual = initialLedgers('proportional', [4, 12, 36]) assert actual == expected, "proportional ledger generation not as expected (2)"
def test_initializeLedgers_split2(): expected = { 0: { 1: Ledger(5, 10), 2: Ledger(15, 10) }, 1: { 0: Ledger(10, 5), 2: Ledger(15, 5) }, 2: { 0: Ledger(10, 15), 1: Ledger(5, 15) }, } actual = initialLedgers('split', [20, 10, 30]) assert actual == expected, "split ledger generation not as expected (2)"
def test_initializeLedgers_split1(): expected = { 0: { 1: Ledger(5, 5), 2: Ledger(5, 5) }, 1: { 0: Ledger(5, 5), 2: Ledger(5, 5) }, 2: { 0: Ledger(5, 5), 1: Ledger(5, 5) }, } actual = initialLedgers('split', [10, 10, 10]) assert actual == expected, "split ledger generation not as expected (1)"
def test_initializeLedgers_constant(c): expected = { 0: { 1: Ledger(c, c), 2: Ledger(c, c) }, 1: { 0: Ledger(c, c), 2: Ledger(c, c) }, 2: { 0: Ledger(c, c), 1: Ledger(c, c) }, } actual = initialLedgers('constant', [0] * 3, c=c) assert actual == expected, "actual ledger does not match expected with constant {}".format( c)
def test_updateLedgersIncremental_multipleRounds_heterogeneous_1(): ledgers = initialLedgers('constant', [0] * 3, c=1) upload_rates = [10, 20, 30] actual_ledgers, _ = propagateN(20, 20, lambda x: x, upload_rates, ledgers) expected_ledgers = { 0: { 1: Ledger(11, 11), 2: Ledger(11, 11) }, 1: { 0: Ledger(11, 11), 2: Ledger(11, 11) }, 2: { 0: Ledger(11, 11), 1: Ledger(11, 11) }, } assert actual_ledgers == expected_ledgers, "actual ledgers do not match expected"
def test_updateLedgersIncremental_multipleRounds_homogeneous_3(c, n, u): ledgers = initialLedgers('constant', [0] * 3, c=c) upload_rates = [u] * 3 actual_ledgers, _ = propagateN(1000 * n, 1000, lambda x: x, upload_rates, ledgers) expected_ledgers = { 0: { 1: Ledger(c + n * 500, c + n * 500), 2: Ledger(c + n * 500, c + n * 500) }, 1: { 0: Ledger(c + n * 500, c + n * 500), 2: Ledger(c + n * 500, c + n * 500) }, 2: { 0: Ledger(c + n * 500, c + n * 500), 1: Ledger(c + n * 500, c + n * 500) }, } assert actual_ledgers == expected_ledgers, "actual ledgers do not match expected"