Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: randomID returns shorter IDs with same amount of entropy (#17)
As reported in #16, the previous implementation of `randomID` used a hashing construction (a) inappropriately, (b) incorrectly. As a result, the IDs that were being generated had a random prefix and then a consistent suffix, like this: ``` 3aa05350d41d8cd98f00b204e9800998ecf8427e f1c841c1d41d8cd98f00b204e9800998ecf8427e e5dde3f7d41d8cd98f00b204e9800998ecf8427e ``` This PR fixes the function to essentially just return the randomly generated prefixes, and omit the suffix entirely. The fixed-suffix was always a mistake and never intended, I just wasn't paying close attention beyond "are the instance database names colliding". I tested this change by running some tests that used `pgtestdb` and intentionally failed, then checking the connection strings that were printed as part of the failing test's logs. Here's an example: ``` testdbconf: postgres://pgtdbuser:pgtdbpass@localhost:5433/testdb_tpl_c2b33a22a68750f84b5af76e9774be0e_inst_a4a3ce6c?sslmode=disabl ``` The key part is `inst_a4a3ce6c`, which is now (a) shorter than before, (b) just as random.
- Loading branch information