diff --git a/Cargo.lock b/Cargo.lock index 39efa8342..92f82b0fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -580,9 +580,10 @@ dependencies = [ [[package]] name = "base64" version = "0.10.1" -source = "git+https://github.com/mesalock-linux/rust-base64-sgx#368a1db999e3005bb1bf2278dbe31f0906441f8c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" dependencies = [ - "sgx_tstd", + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -596,10 +597,9 @@ dependencies = [ [[package]] name = "base64" version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +source = "git+https://github.com/mesalock-linux/rust-base64-sgx#368a1db999e3005bb1bf2278dbe31f0906441f8c" dependencies = [ - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "sgx_tstd", ] [[package]] @@ -666,23 +666,23 @@ dependencies = [ [[package]] name = "block-buffer" version = "0.7.3" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding 0.1.4", - "byte-tools 0.3.1 (git+https://github.com/mesalock-linux/rustcrypto-utils-sgx)", - "byteorder 1.3.4 (git+https://github.com/mesalock-linux/byteorder-sgx)", + "block-padding 0.1.5", + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.12.3", ] [[package]] name = "block-buffer" version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" dependencies = [ - "block-padding 0.1.5", - "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding 0.1.4", + "byte-tools 0.3.1 (git+https://github.com/mesalock-linux/rustcrypto-utils-sgx)", + "byteorder 1.3.4 (git+https://github.com/mesalock-linux/byteorder-sgx)", "generic-array 0.12.3", ] @@ -772,13 +772,19 @@ checksum = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" [[package]] name = "byte-tools" version = "0.3.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byte-tools" version = "0.3.1" +source = "git+https://github.com/mesalock-linux/rustcrypto-utils-sgx#07ebf780554e018037f750186d61ea9bdc031148" + +[[package]] +name = "byteorder" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "byteorder" @@ -788,12 +794,6 @@ dependencies = [ "sgx_tstd", ] -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - [[package]] name = "bytes" version = "0.4.12" @@ -1149,20 +1149,20 @@ dependencies = [ [[package]] name = "crypto-mac" version = "0.8.0" -source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.12.3", - "subtle 2.2.2", + "generic-array 0.14.4", + "subtle 2.3.0", ] [[package]] name = "crypto-mac" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" dependencies = [ - "generic-array 0.14.4", - "subtle 2.3.0", + "generic-array 0.12.3", + "subtle 2.2.2", ] [[package]] @@ -1232,19 +1232,19 @@ dependencies = [ [[package]] name = "digest" version = "0.8.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ "generic-array 0.12.3", - "sgx_tstd", ] [[package]] name = "digest" version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" dependencies = [ "generic-array 0.12.3", + "sgx_tstd", ] [[package]] @@ -1702,8 +1702,8 @@ dependencies = [ "hex", "libsecp256k1 0.3.5", "libsecp256k1 0.4.0", - "log 0.4.11 (git+https://github.com/mesalock-linux/log-sgx?rev=sgx_1.1.3)", "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (git+https://github.com/mesalock-linux/log-sgx?rev=sgx_1.1.3)", "parity-scale-codec", "rand 0.6.5", "rand 0.7.3 (git+https://github.com/mesalock-linux/rand-sgx?rev=v0.7.3_sgx1.1.3)", @@ -2046,20 +2046,20 @@ dependencies = [ [[package]] name = "hmac" version = "0.7.1" -source = "git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx#e8e1410b9c82d2e59da42fa8b0d8ed38e80a203c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" dependencies = [ - "crypto-mac 0.8.0 (git+https://github.com/mesalock-linux/rustcrypto-traits-sgx)", - "digest 0.8.1 (git+https://github.com/mesalock-linux/rustcrypto-traits-sgx)", + "crypto-mac 0.7.0", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "hmac" version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +source = "git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx#e8e1410b9c82d2e59da42fa8b0d8ed38e80a203c" dependencies = [ - "crypto-mac 0.7.0", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crypto-mac 0.8.0 (git+https://github.com/mesalock-linux/rustcrypto-traits-sgx)", + "digest 0.8.1 (git+https://github.com/mesalock-linux/rustcrypto-traits-sgx)", ] [[package]] @@ -2075,21 +2075,21 @@ dependencies = [ [[package]] name = "hmac-drbg" version = "0.1.2" -source = "git+https://github.com/mesalock-linux/hmac-drbg-rs-sgx#89d6b0113157599417af867a8d2b4afd5c6f1946" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" dependencies = [ - "generic-array 0.12.3", - "hmac 0.7.1 (git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx)", + "digest 0.6.2", + "generic-array 0.8.3", + "hmac 0.4.2", ] [[package]] name = "hmac-drbg" version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" +source = "git+https://github.com/mesalock-linux/hmac-drbg-rs-sgx#89d6b0113157599417af867a8d2b4afd5c6f1946" dependencies = [ - "digest 0.6.2", - "generic-array 0.8.3", - "hmac 0.4.2", + "generic-array 0.12.3", + "hmac 0.7.1 (git+https://github.com/mesalock-linux/rustcrypto-MACs-sgx)", ] [[package]] @@ -2128,23 +2128,23 @@ dependencies = [ [[package]] name = "http" version = "0.2.1" -source = "git+https://github.com/mesalock-linux/http-sgx?rev=sgx_1.1.3#62544a1833f98f1810a44877c5f1efe45f5327c0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" dependencies = [ - "bytes 0.5.4", - "fnv 1.0.6", - "itoa 0.4.5", - "sgx_tstd", + "bytes 0.5.6", + "fnv 1.0.7", + "itoa 0.4.6", ] [[package]] name = "http" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +source = "git+https://github.com/mesalock-linux/http-sgx?rev=sgx_1.1.3#62544a1833f98f1810a44877c5f1efe45f5327c0" dependencies = [ - "bytes 0.5.6", - "fnv 1.0.7", - "itoa 0.4.6", + "bytes 0.5.4", + "fnv 1.0.6", + "itoa 0.4.5", + "sgx_tstd", ] [[package]] @@ -2651,19 +2651,19 @@ dependencies = [ [[package]] name = "log" version = "0.4.11" -source = "git+https://github.com/mesalock-linux/log-sgx?rev=sgx_1.1.3#5a057d237cf96e9137de08387eb70105d5705648" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ "cfg-if 0.1.10", - "sgx_tstd", ] [[package]] name = "log" version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +source = "git+https://github.com/mesalock-linux/log-sgx?rev=sgx_1.1.3#5a057d237cf96e9137de08387eb70105d5705648" dependencies = [ "cfg-if 0.1.10", + "sgx_tstd", ] [[package]] @@ -2929,7 +2929,7 @@ dependencies = [ [[package]] name = "once_cell" version = "1.4.0" -source = "git+https://github.com/mesalock-linux/once_cell-sgx#cefcaa03fed4d85276b3235d875f1b45d399cc3c" +source = "git+https://github.com/mesalock-linux/once_cell-sgx?rev=sgx_1.1.3#cefcaa03fed4d85276b3235d875f1b45d399cc3c" dependencies = [ "sgx_tstd", ] @@ -2937,7 +2937,7 @@ dependencies = [ [[package]] name = "once_cell" version = "1.4.0" -source = "git+https://github.com/mesalock-linux/once_cell-sgx?rev=sgx_1.1.3#cefcaa03fed4d85276b3235d875f1b45d399cc3c" +source = "git+https://github.com/mesalock-linux/once_cell-sgx#cefcaa03fed4d85276b3235d875f1b45d399cc3c" dependencies = [ "sgx_tstd", ] @@ -3385,6 +3385,19 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.15", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0", +] + [[package]] name = "rand" version = "0.7.3" @@ -3407,19 +3420,6 @@ dependencies = [ "sgx_tstd", ] -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.15", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.2.0", -] - [[package]] name = "rand_chacha" version = "0.1.1" @@ -3478,16 +3478,16 @@ checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" [[package]] name = "rand_core" version = "0.5.1" -source = "git+https://github.com/mesalock-linux/rand-sgx?tag=v0.7.3_sgx1.1.3#55697c5a4007d13e8d5f37be7216be1b18fb8ebf" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.14", - "sgx_tstd", + "getrandom 0.1.15", ] [[package]] name = "rand_core" version = "0.5.1" -source = "git+https://github.com/mesalock-linux/rand-sgx?rev=v0.7.3_sgx1.1.3#55697c5a4007d13e8d5f37be7216be1b18fb8ebf" +source = "git+https://github.com/mesalock-linux/rand-sgx?tag=v0.7.3_sgx1.1.3#55697c5a4007d13e8d5f37be7216be1b18fb8ebf" dependencies = [ "getrandom 0.1.14", "sgx_tstd", @@ -3496,10 +3496,10 @@ dependencies = [ [[package]] name = "rand_core" version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +source = "git+https://github.com/mesalock-linux/rand-sgx?rev=v0.7.3_sgx1.1.3#55697c5a4007d13e8d5f37be7216be1b18fb8ebf" dependencies = [ - "getrandom 0.1.15", + "getrandom 0.1.14", + "sgx_tstd", ] [[package]] @@ -3813,19 +3813,6 @@ dependencies = [ "webpki 0.21.4", ] -[[package]] -name = "rustls" -version = "0.19.0" -source = "git+https://github.com/mesalock-linux/rustls?branch=mesalock_sgx#95b5e79dc24b02f3ce424437eb9698509d0baf58" -dependencies = [ - "base64 0.10.1 (git+https://github.com/mesalock-linux/rust-base64-sgx)", - "log 0.4.8", - "ring 0.16.19", - "sct 0.6.0 (git+https://github.com/mesalock-linux/sct.rs?branch=mesalock_sgx)", - "sgx_tstd", - "webpki 0.21.4", -] - [[package]] name = "rustls" version = "0.19.0" @@ -3839,6 +3826,19 @@ dependencies = [ "webpki 0.21.3", ] +[[package]] +name = "rustls" +version = "0.19.0" +source = "git+https://github.com/mesalock-linux/rustls?branch=mesalock_sgx#95b5e79dc24b02f3ce424437eb9698509d0baf58" +dependencies = [ + "base64 0.10.1 (git+https://github.com/mesalock-linux/rust-base64-sgx)", + "log 0.4.8", + "ring 0.16.19", + "sct 0.6.0 (git+https://github.com/mesalock-linux/sct.rs?branch=mesalock_sgx)", + "sgx_tstd", + "webpki 0.21.4", +] + [[package]] name = "ryu" version = "1.0.5" @@ -3889,20 +3889,20 @@ dependencies = [ [[package]] name = "sct" version = "0.6.0" -source = "git+https://github.com/mesalock-linux/sct.rs?branch=mesalock_sgx#c4d859cca232e6c9d88ca12048df3bc26e1ed4ad" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" dependencies = [ - "ring 0.16.19", - "sgx_tstd", + "ring 0.16.15", "untrusted", ] [[package]] name = "sct" version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +source = "git+https://github.com/mesalock-linux/sct.rs?branch=mesalock_sgx#c4d859cca232e6c9d88ca12048df3bc26e1ed4ad" dependencies = [ - "ring 0.16.15", + "ring 0.16.19", + "sgx_tstd", "untrusted", ] @@ -4035,18 +4035,18 @@ dependencies = [ [[package]] name = "serde" version = "1.0.118" -source = "git+https://github.com/mesalock-linux/serde-sgx.git#db0226f1d5d70fca6b96af2c285851502204e21c" +source = "git+https://github.com/mesalock-linux/serde-sgx.git?rev=sgx_1.1.3#db0226f1d5d70fca6b96af2c285851502204e21c" dependencies = [ - "serde_derive 1.0.118 (git+https://github.com/mesalock-linux/serde-sgx.git)", + "serde_derive 1.0.118 (git+https://github.com/mesalock-linux/serde-sgx.git?rev=sgx_1.1.3)", "sgx_tstd", ] [[package]] name = "serde" version = "1.0.118" -source = "git+https://github.com/mesalock-linux/serde-sgx.git?rev=sgx_1.1.3#db0226f1d5d70fca6b96af2c285851502204e21c" +source = "git+https://github.com/mesalock-linux/serde-sgx.git#db0226f1d5d70fca6b96af2c285851502204e21c" dependencies = [ - "serde_derive 1.0.118 (git+https://github.com/mesalock-linux/serde-sgx.git?rev=sgx_1.1.3)", + "serde_derive 1.0.118 (git+https://github.com/mesalock-linux/serde-sgx.git)", "sgx_tstd", ] @@ -4083,7 +4083,7 @@ dependencies = [ [[package]] name = "serde_derive" version = "1.0.118" -source = "git+https://github.com/mesalock-linux/serde-sgx.git#db0226f1d5d70fca6b96af2c285851502204e21c" +source = "git+https://github.com/mesalock-linux/serde-sgx.git?rev=sgx_1.1.3#db0226f1d5d70fca6b96af2c285851502204e21c" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", @@ -4093,7 +4093,7 @@ dependencies = [ [[package]] name = "serde_derive" version = "1.0.118" -source = "git+https://github.com/mesalock-linux/serde-sgx.git?rev=sgx_1.1.3#db0226f1d5d70fca6b96af2c285851502204e21c" +source = "git+https://github.com/mesalock-linux/serde-sgx.git#db0226f1d5d70fca6b96af2c285851502204e21c" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", @@ -4477,7 +4477,8 @@ checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" [[package]] name = "stream-cipher" version = "0.3.2" -source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" dependencies = [ "generic-array 0.12.3", ] @@ -4485,8 +4486,7 @@ dependencies = [ [[package]] name = "stream-cipher" version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" +source = "git+https://github.com/mesalock-linux/rustcrypto-traits-sgx#7a5cb154f438c2401b3d8e37de96dd0acf8f493e" dependencies = [ "generic-array 0.12.3", ] @@ -5203,18 +5203,18 @@ dependencies = [ [[package]] name = "unicase" version = "2.6.0" -source = "git+https://github.com/mesalock-linux/unicase-sgx#0b0519348572927118af47af3da4da9ffdca8ec6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" dependencies = [ - "sgx_tstd", "version_check", ] [[package]] name = "unicase" version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +source = "git+https://github.com/mesalock-linux/unicase-sgx#0b0519348572927118af47af3da4da9ffdca8ec6" dependencies = [ + "sgx_tstd", "version_check", ] diff --git a/example/erc20/server/src/tests.rs b/example/erc20/server/src/tests.rs index 2bbb977e7..205dd8c70 100644 --- a/example/erc20/server/src/tests.rs +++ b/example/erc20/server/src/tests.rs @@ -7,6 +7,7 @@ use frame_common::crypto::AccountId; use frame_runtime::primitives::U64; use frame_treekem::{DhPubKey, EciesCiphertext}; use integration_tests::set_env_vars; +use sgx_types::sgx_destroy_enclave; use std::{fs::File, io::BufReader, path::Path, str::FromStr, time}; use web3::{ contract::{Contract, Options}, @@ -40,6 +41,9 @@ async fn test_deploy_post() { assert!(resp.status().is_success(), "response: {:?}", resp); let contract_addr: erc20_api::deploy::post::Response = test::read_body_json(resp).await; println!("contract address: {:?}", contract_addr); + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -141,6 +145,9 @@ async fn test_multiple_messages() { assert!(resp.status().is_success(), "response: {:?}", resp); let balance: erc20_api::state::get::Response = test::read_body_json(resp).await; assert_eq!(balance.0.as_raw(), 50); + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -257,6 +264,9 @@ async fn test_skip_invalid_event() { assert!(resp.status().is_success(), "response: {:?}", resp); let balance: erc20_api::state::get::Response = test::read_body_json(resp).await; assert_eq!(balance.0.as_raw(), 90); + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -452,6 +462,12 @@ async fn test_node_recovery() { assert!(resp.status().is_success(), "response: {:?}", resp); let balance: erc20_api::state::get::Response = test::read_body_json(resp).await; assert_eq!(balance.0.as_raw(), 80); + unsafe { + sgx_destroy_enclave(eid); + } + unsafe { + sgx_destroy_enclave(recovered_eid); + } } #[actix_rt::test] @@ -619,6 +635,12 @@ async fn test_join_group_then_handshake() { assert!(resp.status().is_success(), "response: {:?}", resp); let balance: erc20_api::state::get::Response = test::read_body_json(resp).await; assert_eq!(balance.0.as_raw(), 90); + unsafe { + sgx_destroy_enclave(eid1); + } + unsafe { + sgx_destroy_enclave(eid2); + } } fn set_server_env_vars() { diff --git a/example/secret-backup/server/src/tests.rs b/example/secret-backup/server/src/tests.rs index 51a94f94e..e455e4811 100644 --- a/example/secret-backup/server/src/tests.rs +++ b/example/secret-backup/server/src/tests.rs @@ -13,6 +13,7 @@ use frame_common::crypto::Ed25519ChallengeResponse; use frame_runtime::primitives::U64; use frame_treekem::{DhPubKey, EciesCiphertext}; use once_cell::sync::Lazy; +use sgx_types::sgx_destroy_enclave; use std::{ env, fs::{self, File}, @@ -172,6 +173,13 @@ async fn test_backup_path_secret() { .get_state::(my_access_policy.clone(), "balance_of") .unwrap(); assert_eq!(my_state, total_supply); + + unsafe { + sgx_destroy_enclave(server_eid); + } + unsafe { + sgx_destroy_enclave(app_eid); + } } #[actix_rt::test] @@ -274,6 +282,13 @@ async fn test_lost_path_secret() { .await; assert!(should_err.is_err()); + + unsafe { + sgx_destroy_enclave(server_eid); + } + unsafe { + sgx_destroy_enclave(app_eid); + } } pub static SUBSCRIBER_INIT: Lazy<()> = Lazy::new(|| { diff --git a/scripts/test.sh b/scripts/test.sh index ae7b42089..d0f5cebcd 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -33,29 +33,19 @@ make DEBUG=1 ENCLAVE_DIR=example/erc20/enclave # Module Tests cd ${ANONIFY_ROOT}/tests/integration -RUST_BACKTRACE=1 RUST_LOG=debug cargo test -- --nocapture +RUST_BACKTRACE=1 RUST_LOG=debug cargo test -j 1 -- --nocapture # ERC20 Application Tests cd ${ANONIFY_ROOT}/example/erc20/server -RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_deploy_post -- --nocapture -sleep 1 -RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_multiple_messages -- --nocapture -sleep 1 -RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_skip_invalid_event -- --nocapture -sleep 1 -RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_node_recovery -- --nocapture -sleep 1 -RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_join_group_then_handshake -- --nocapture +RUST_BACKTRACE=1 RUST_LOG=debug cargo test -j 1 -- --test-threads 1 -- --nocapture # Secret Backup Application Tests export ENCLAVE_PKG_NAME=secret_backup unset BACKUP cd ${ANONIFY_ROOT}/example/secret-backup/server -RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_backup_path_secret -- --nocapture -sleep 1 -RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_lost_path_secret -- --nocapture +RUST_BACKTRACE=1 RUST_LOG=debug cargo test -j 1 -- --nocapture # # Unit Tests diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index 8effee9c7..700609372 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -11,6 +11,7 @@ use frame_common::{ use frame_host::EnclaveDir; use frame_runtime::primitives::{Approved, U64}; use frame_treekem::{DhPubKey, EciesCiphertext}; +use sgx_types::sgx_destroy_enclave; use sgx_types::*; use std::{collections::BTreeMap, env, fs::File, io::BufReader, str::FromStr}; use web3::{ @@ -128,6 +129,10 @@ async fn test_integration_eth_construct() { assert_eq!(owner_account_id, my_access_policy.into_account_id()); assert_eq!(my_balance, total_supply); assert_eq!(actual_total_supply, total_supply); + + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -224,6 +229,10 @@ async fn test_auto_notification() { ); assert_eq!(updated_state[0].mem_id.as_raw(), 0); assert_eq!(updated_state[0].state, U64::from_raw(70)); + + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -333,6 +342,10 @@ async fn test_integration_eth_transfer() { assert_eq!(my_updated_state, U64::from_raw(70)); assert_eq!(other_updated_state, amount); assert_eq!(third_updated_state, U64::zero()); + + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -416,6 +429,10 @@ async fn test_key_rotation() { assert_eq!(my_state, total_supply); assert_eq!(other_state, U64::zero()); assert_eq!(third_state, U64::zero()); + + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -520,6 +537,10 @@ async fn test_integration_eth_approve() { }); assert_eq!(my_state, want_my_state); assert_eq!(other_state, Approved::default()); + + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -716,6 +737,10 @@ async fn test_integration_eth_transfer_from() { assert_eq!(my_state_approved, want_my_state); assert_eq!(other_state_approved, Approved::default()); assert_eq!(third_state_approved, Approved::default()); + + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -810,6 +835,10 @@ async fn test_integration_eth_mint() { assert_eq!(actual_total_supply, U64::from_raw(150)); assert_eq!(owner_balance, U64::from_raw(100)); assert_eq!(other_balance, amount); + + unsafe { + sgx_destroy_enclave(eid); + } } #[actix_rt::test] @@ -922,6 +951,10 @@ async fn test_integration_eth_burn() { assert_eq!(actual_total_supply, U64::from_raw(80)); // 100 - 20(burn) assert_eq!(owner_balance, U64::from_raw(70)); // 100 - 30(transfer) assert_eq!(other_balance, U64::from_raw(10)); // 30 - 20(burn) + + unsafe { + sgx_destroy_enclave(eid); + } } lazy_static! {