EnAccess / EnAccess/OpenPAYGO-python
[Bug]: Discrepancy of extended Token with legacy library
- Lenguaje dominante
- Python
- Estrellas
- 15
- Forks
- 15
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
### Preflight Checklist
- [x] I have read the [Contributing Guidelines](https://github.com/EnAccess/OpenPAYGO-python/blob/main/CONTRIBUTING.md) for this project, if it exists.
- [x] I agree to follow the [Code of Conduct](https://github.com/EnAccess/OpenPAYGO-python/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [x] I have searched the [issue tracker](https://github.com/EnAccess/OpenPAYGO-python/issues) for a feature request that matches the one I want to file, without success.
### Expected Behavior
Legacy and new library should generate the same extended tokens.
### Actual Behavior
When generating extended tokens there is a difference for `ADD_TIME` tokens.
**New lib:**
```python
# OpenPAYGO-python
from openpaygo import OpenPAYGOTokenEncoder, TokenType
encoder = OpenPAYGOTokenEncoder()
new_count, final_token = encoder.generate_token(
secret_key="bc41ec9530f6dac86b1a29ab82edc5fb",
count=2,
value=1,
token_type=TokenType.ADD_TIME,
starting_code=516959010,
restricted_digit_set=False,
extended_token=True,
)
print(f"{new_count=}")
print(f"{final_token=}")
```
yields
```sh
new_count=4
final_token='584694959011'
```
**Legacy:**
```python
# OpenPAYGO Token
import codecs
from importlib import import_module
openpaygo_token = import_module("openpaygo-token")
encoder = openpaygo_token.OPAYGOEncoder()
shared = openpaygo_token.OPAYGOShared
new_count, final_token = encoder.generate_extended_token(
key=codecs.decode("bc41ec9530f6dac86b1a29ab82edc5fb", "hex"),
count=2,
value=1,
# mode=shared.TOKEN_TYPE_ADD_TIME,
starting_code=516959010,
restricted_digit_set=False,
)
print(f"{new_count=}")
print(f"{final_token=}")
```
```sh
new_count=3
final_token='660362959011'
```
### Steps to reproduce
Run the code from above.
This might be related to the legacy being hardcoded to `SET_TIME` for extended mode. Is the expected behaviour?
### What operating system(s) are you using?
macOS
### Additional Information
_No response_
Guía de contribución
Línea de trabajo
Start by running the Python examples in the issue and compare OpenPAYGOTokenEncoder.generate_token with the legacy generate_extended_token for an extended ADD_TIME token. Trace how extended-mode token type and count are handled, then verify the result against the legacy output or an explicitly confirmed expected behavior. The issue names no repository files or tests.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100