Doug Hoyte on Nostr: This is awesome, thank you! I'm trying to create a harness for this so we can run it ...
This is awesome, thank you!
I'm trying to create a harness for this so we can run it against the test-suite used by the C++ and JS implementations. For example, here's the C++ harness:
https://github.com/hoytech/negentropy/blob/master/test/cpp/harness.cppThis is as far as I got:
https://gist.github.com/hoytech/96e65fc488fc39c2e782830f38727391This is pretty much the first Rust code I've ever written, sorry about the bad quality. The problem I'm running into is that the reconcile() and reconcile_with_ids() methods seem to return String. If I understand rightly, Rust strings must be utf-8 encoded right?
In the current implementations, the reconcile messages must be in an 8-bit clean medium (or hex encoded). Same with the IDs (since they are typically hash function outputs). In C++ I use std::string because this allows any u8 values (and doesn't care anywhere about utf-8). In JS I allow Uint8Array values *or* hex-encoded strings.
Can we make the rust interface standardise on something 8-bit clean? Vec<u8> or some such? Or it's very possible I'm misinterpreting the code here. Any pointers are very much appreciated.
Published at
2023-09-11 20:24:08Event JSON
{
"id": "7acda50041a59ea98cb95430f95eabf8dc0127fe511674b2ed645c73570d405b",
"pubkey": "218238431393959d6c8617a3bd899303a96609b44a644e973891038a7de8622d",
"created_at": 1694463848,
"kind": 1,
"tags": [
[
"e",
"0ac14895356511ee786de1fb0c20cd7c3351fa216663dc1999e882b7db02b953",
"",
"root"
],
[
"p",
"68d81165918100b7da43fc28f7d1fc12554466e1115886b9e7bb326f65ec4272"
]
],
"content": "This is awesome, thank you!\n\nI'm trying to create a harness for this so we can run it against the test-suite used by the C++ and JS implementations. For example, here's the C++ harness:\n\nhttps://github.com/hoytech/negentropy/blob/master/test/cpp/harness.cpp\n\nThis is as far as I got:\n\nhttps://gist.github.com/hoytech/96e65fc488fc39c2e782830f38727391\n\nThis is pretty much the first Rust code I've ever written, sorry about the bad quality. The problem I'm running into is that the reconcile() and reconcile_with_ids() methods seem to return String. If I understand rightly, Rust strings must be utf-8 encoded right?\n\nIn the current implementations, the reconcile messages must be in an 8-bit clean medium (or hex encoded). Same with the IDs (since they are typically hash function outputs). In C++ I use std::string because this allows any u8 values (and doesn't care anywhere about utf-8). In JS I allow Uint8Array values *or* hex-encoded strings.\n\nCan we make the rust interface standardise on something 8-bit clean? Vec\u003cu8\u003e or some such? Or it's very possible I'm misinterpreting the code here. Any pointers are very much appreciated.",
"sig": "8b40ba40636d297dc9c146660a5d46379f0223e28d94643f2131abe54a6bff1528a57799ee50019acd1d2bd1382456559d08e0c4d49c64c63f9bbbd695a9eeb8"
}