| 2610 | |
| 2611 | @pytest.mark.parametrize("config", JUMP_TEST_DATA) |
| 2612 | def test_jumped(config): |
| 2613 | # Each config contains the initial seed, a number of raw steps |
| 2614 | # the sha256 hashes of the initial and the final states' keys and |
| 2615 | # the position of the initial and the final state. |
| 2616 | # These were produced using the original C implementation. |
| 2617 | seed = config["seed"] |
| 2618 | steps = config["steps"] |
| 2619 | |
| 2620 | mt19937 = MT19937(seed) |
| 2621 | # Burn step |
| 2622 | mt19937.random_raw(steps) |
| 2623 | key = mt19937.state["state"]["key"] |
| 2624 | if sys.byteorder == 'big': |
| 2625 | key = key.byteswap() |
| 2626 | sha256 = hashlib.sha256(key) |
| 2627 | assert mt19937.state["state"]["pos"] == config["initial"]["pos"] |
| 2628 | assert sha256.hexdigest() == config["initial"]["key_sha256"] |
| 2629 | |
| 2630 | jumped = mt19937.jumped() |
| 2631 | key = jumped.state["state"]["key"] |
| 2632 | if sys.byteorder == 'big': |
| 2633 | key = key.byteswap() |
| 2634 | sha256 = hashlib.sha256(key) |
| 2635 | assert jumped.state["state"]["pos"] == config["jumped"]["pos"] |
| 2636 | assert sha256.hexdigest() == config["jumped"]["key_sha256"] |
| 2637 | |
| 2638 | |
| 2639 | def test_broadcast_size_error(): |