diff options
| author | J08nY | 2025-03-08 15:31:09 +0100 |
|---|---|---|
| committer | J08nY | 2025-03-08 15:31:09 +0100 |
| commit | 81f4d8ff8dab2a7884f0d74f23b3d78142eb176a (patch) | |
| tree | 9d8e36a12f0bb1068bbbbd7c749a7beea1b8fd5d /test | |
| parent | 5837599a7c80237776196e4c451810e121b74c54 (diff) | |
| download | pyecsca-81f4d8ff8dab2a7884f0d74f23b3d78142eb176a.tar.gz pyecsca-81f4d8ff8dab2a7884f0d74f23b3d78142eb176a.tar.zst pyecsca-81f4d8ff8dab2a7884f0d74f23b3d78142eb176a.zip | |
Improve context handling and make some stuff zero copy.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ec/test_context.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ec/test_context.py b/test/ec/test_context.py index 9ad8b52..f76995b 100644 --- a/test/ec/test_context.py +++ b/test/ec/test_context.py @@ -89,6 +89,38 @@ def test_default_no_enter(): with local(DefaultContext()) as default, pytest.raises(ValueError): default.exit_action(RandomModAction(7)) +def test_multiple_enter(mult): + default = DefaultContext() + with local(default) as ctx1: + mult.multiply(59) + + with local(default) as ctx2: + mult.multiply(135) + + assert len(default.actions) == 0 + assert len(ctx1.actions) == len(ctx2.actions) + +def test_multiple_enter_chained(mult): + default = DefaultContext() + with local(default) as ctx1: + mult.multiply(59) + + with local(ctx1) as ctx2: + mult.multiply(135) + + assert len(default.actions) == 0 + assert 2 * len(ctx1.actions) == len(ctx2.actions) + +def test_multiple_enter_no_copy(mult): + default = DefaultContext() + with local(default, copy=False) as ctx1: + mult.multiply(59) + + with local(default, copy=False) as ctx2: + mult.multiply(135) + + assert len(default.actions) == len(ctx1.actions) + assert len(ctx1.actions) == len(ctx2.actions) def test_path(mult, secp128r1): with local(PathContext([0, 1])) as ctx: |
