I used nix-cargo-integration (which builds on dream2nix). This hides a lot of complexity with reasonable default configurations. It also uses flake-parts, so making the build.nix a flake module seemed like a natural choice, but it diverges from the current status quo, so there's a separate issue to bring everything to the same conventions.
Types
Integer: num_bigint is used in cardano_serialisation_lib
ByteString: &[u8] or Vec<u8> are the obvious choices, I'm not sure if there's too much difference from the end-user standpoint.
Json serialisers
I followed the same principles that we used in Hs and Ps packages: to_json instances serialise to a Value (intermediary JSON representation). However I'm not sure, if this is the most convenient way from the end-user perspective, we will have to experiment with this later.
Another question mark is error messages: I'm still not familiar with the messages serde returns, so I basically copied the error messages from the Haskell implementation. To make this library feel more natural, I think these should be adjusted in the future.
Property testing
There are two popular options in Rust for property testing: quickcheck and proptest.
The former is a simple library, mostly following the Haskell implementation and design principles. proptest is a more robust (and a little bit slower) tool, with a lot of nice features.
I decided to go with the latter one, as it allowed me to write simply implement BigInt generators. Also, I simply liked the API of the library.
One area which is still not clear to me is proptest-regressions. When a proptest fails, the input values are stored in the project directory, and used in later tests. I decided to put this into .gitignore, I'm not exactly sure if this is working exactly as I desired (e.g. these tests logs remain even if I change the tests).
Closes: #103
Some notes on the implementaton:
nix integration
I used nix-cargo-integration (which builds on dream2nix). This hides a lot of complexity with reasonable default configurations. It also uses flake-parts, so making the
build.nix
a flake module seemed like a natural choice, but it diverges from the current status quo, so there's a separate issue to bring everything to the same conventions.Types
Integer: num_bigint is used in cardano_serialisation_lib ByteString:
&[u8]
orVec<u8>
are the obvious choices, I'm not sure if there's too much difference from the end-user standpoint.Json serialisers
I followed the same principles that we used in Hs and Ps packages:
to_json
instances serialise to aValue
(intermediary JSON representation). However I'm not sure, if this is the most convenient way from the end-user perspective, we will have to experiment with this later.Another question mark is error messages: I'm still not familiar with the messages
serde
returns, so I basically copied the error messages from the Haskell implementation. To make this library feel more natural, I think these should be adjusted in the future.Property testing
There are two popular options in Rust for property testing:
quickcheck
andproptest
. The former is a simple library, mostly following the Haskell implementation and design principles.proptest
is a more robust (and a little bit slower) tool, with a lot of nice features. I decided to go with the latter one, as it allowed me to write simply implement BigInt generators. Also, I simply liked the API of the library. One area which is still not clear to me isproptest-regressions
. When a proptest fails, the input values are stored in the project directory, and used in later tests. I decided to put this into.gitignore
, I'm not exactly sure if this is working exactly as I desired (e.g. these tests logs remain even if I change the tests).Links to related issues
109
110