(config)
| 2654 | |
| 2655 | @pytest.mark.parametrize("config", JUMP_TEST_DATA) |
| 2656 | def test_jumped(config): |
| 2657 | # Each config contains the initial seed, a number of raw steps |
| 2658 | # the sha256 hashes of the initial and the final states' keys and |
| 2659 | # the position of the initial and the final state. |
| 2660 | # These were produced using the original C implementation. |
| 2661 | seed = config["seed"] |
| 2662 | steps = config["steps"] |
| 2663 | |
| 2664 | mt19937 = MT19937(seed) |
| 2665 | # Burn step |
| 2666 | mt19937.random_raw(steps) |
| 2667 | key = mt19937.state["state"]["key"] |
| 2668 | if sys.byteorder == 'big': |
| 2669 | key = key.byteswap() |
| 2670 | sha256 = hashlib.sha256(key) |
| 2671 | assert mt19937.state["state"]["pos"] == config["initial"]["pos"] |
| 2672 | assert sha256.hexdigest() == config["initial"]["key_sha256"] |
| 2673 | |
| 2674 | jumped = mt19937.jumped() |
| 2675 | key = jumped.state["state"]["key"] |
| 2676 | if sys.byteorder == 'big': |
| 2677 | key = key.byteswap() |
| 2678 | sha256 = hashlib.sha256(key) |
| 2679 | assert jumped.state["state"]["pos"] == config["jumped"]["pos"] |
| 2680 | assert sha256.hexdigest() == config["jumped"]["key_sha256"] |
| 2681 | |
| 2682 | |
| 2683 | def test_broadcast_size_error(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…