integritee-network / pallets

Other
10 stars 14 forks source link

Introduce trait `VerySgxReport` and make it an associated type of the teerex pallet #153

Open clangenb opened 1 year ago

clangenb commented 1 year ago

The current procedure of with the compile flag seems like a hack to me. To increase testability and remove the need to test with different feature flags we should do something like this:


pub trait pallet_teerex::Config {
    // other stuff

   /// type that can verify an IAS or an DCAP sgx remote attestation report
   type VerifySGXReport: VerifySGXReport 

}

struct SgxProductionVerifier;

impl VerifySGXReport for SgxProductionVerifier {
   // implement the real checks
}

struct SgxMockVerifier;

impl VerifySGXReport for SgxMockVerifier {
   // do the the stuff we currently do with `--features skip-ias-check`
}

Then, instead of having to test with different feature flags, we can run tests on both of our verifier structs, and if we want we can run tests on two mock runtimes, one with each verifier.