Compare commits
	
		
			No commits in common. "39ee3cd84b933e2b2b5ae50ed3d24cf87e48bc21" and "7b1bb98074037704025a0f98c29dc6601cf15586" have entirely different histories.
		
	
	
		
			39ee3cd84b
			...
			7b1bb98074
		
	
		
							
								
								
									
										363
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										363
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @ -440,7 +440,7 @@ dependencies = [ | |||||||
|  "miniz_oxide", |  "miniz_oxide", | ||||||
|  "object", |  "object", | ||||||
|  "rustc-demangle", |  "rustc-demangle", | ||||||
|  "windows-targets", |  "windows-targets 0.52.6", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -826,16 +826,6 @@ version = "0.3.1" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" | checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "core-foundation" |  | ||||||
| version = "0.9.4" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" |  | ||||||
| dependencies = [ |  | ||||||
|  "core-foundation-sys", |  | ||||||
|  "libc", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "core-foundation-sys" | name = "core-foundation-sys" | ||||||
| version = "0.8.7" | version = "0.8.7" | ||||||
| @ -1268,21 +1258,6 @@ version = "0.1.5" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" | checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "foreign-types" |  | ||||||
| version = "0.3.2" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" |  | ||||||
| dependencies = [ |  | ||||||
|  "foreign-types-shared", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] |  | ||||||
| name = "foreign-types-shared" |  | ||||||
| version = "0.1.1" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "form_urlencoded" | name = "form_urlencoded" | ||||||
| version = "1.2.1" | version = "1.2.1" | ||||||
| @ -1723,7 +1698,7 @@ dependencies = [ | |||||||
|  "tokio", |  "tokio", | ||||||
|  "tokio-rustls", |  "tokio-rustls", | ||||||
|  "tower-service", |  "tower-service", | ||||||
|  "webpki-roots 0.26.8", |  "webpki-roots", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -1739,46 +1714,24 @@ dependencies = [ | |||||||
|  "tower-service", |  "tower-service", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "hyper-tls" |  | ||||||
| version = "0.6.0" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" |  | ||||||
| dependencies = [ |  | ||||||
|  "bytes", |  | ||||||
|  "http-body-util", |  | ||||||
|  "hyper", |  | ||||||
|  "hyper-util", |  | ||||||
|  "native-tls", |  | ||||||
|  "tokio", |  | ||||||
|  "tokio-native-tls", |  | ||||||
|  "tower-service", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "hyper-util" | name = "hyper-util" | ||||||
| version = "0.1.14" | version = "0.1.11" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "dc2fdfdbff08affe55bb779f33b053aa1fe5dd5b54c257343c17edfa55711bdb" | checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "base64 0.22.1", |  | ||||||
|  "bytes", |  "bytes", | ||||||
|  "futures-channel", |  "futures-channel", | ||||||
|  "futures-core", |  | ||||||
|  "futures-util", |  "futures-util", | ||||||
|  "http", |  "http", | ||||||
|  "http-body", |  "http-body", | ||||||
|  "hyper", |  "hyper", | ||||||
|  "ipnet", |  | ||||||
|  "libc", |  "libc", | ||||||
|  "percent-encoding", |  | ||||||
|  "pin-project-lite", |  "pin-project-lite", | ||||||
|  "socket2", |  "socket2", | ||||||
|  "system-configuration", |  | ||||||
|  "tokio", |  "tokio", | ||||||
|  "tower-service", |  "tower-service", | ||||||
|  "tracing", |  "tracing", | ||||||
|  "windows-registry", |  | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -1987,16 +1940,6 @@ version = "2.11.0" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" | checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "iri-string" |  | ||||||
| version = "0.7.8" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" |  | ||||||
| dependencies = [ |  | ||||||
|  "memchr", |  | ||||||
|  "serde", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "is_terminal_polyfill" | name = "is_terminal_polyfill" | ||||||
| version = "1.70.1" | version = "1.70.1" | ||||||
| @ -2362,23 +2305,6 @@ dependencies = [ | |||||||
|  "rand 0.8.5", |  "rand 0.8.5", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "native-tls" |  | ||||||
| version = "0.2.14" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" |  | ||||||
| dependencies = [ |  | ||||||
|  "libc", |  | ||||||
|  "log", |  | ||||||
|  "openssl", |  | ||||||
|  "openssl-probe", |  | ||||||
|  "openssl-sys", |  | ||||||
|  "schannel", |  | ||||||
|  "security-framework", |  | ||||||
|  "security-framework-sys", |  | ||||||
|  "tempfile", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "ndarray" | name = "ndarray" | ||||||
| version = "0.15.6" | version = "0.15.6" | ||||||
| @ -2531,50 +2457,6 @@ version = "1.21.3" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" | checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "openssl" |  | ||||||
| version = "0.10.73" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" |  | ||||||
| dependencies = [ |  | ||||||
|  "bitflags", |  | ||||||
|  "cfg-if", |  | ||||||
|  "foreign-types", |  | ||||||
|  "libc", |  | ||||||
|  "once_cell", |  | ||||||
|  "openssl-macros", |  | ||||||
|  "openssl-sys", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] |  | ||||||
| name = "openssl-macros" |  | ||||||
| version = "0.1.1" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" |  | ||||||
| dependencies = [ |  | ||||||
|  "proc-macro2", |  | ||||||
|  "quote", |  | ||||||
|  "syn 2.0.100", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] |  | ||||||
| name = "openssl-probe" |  | ||||||
| version = "0.1.6" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" |  | ||||||
| 
 |  | ||||||
| [[package]] |  | ||||||
| name = "openssl-sys" |  | ||||||
| version = "0.9.109" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" |  | ||||||
| dependencies = [ |  | ||||||
|  "cc", |  | ||||||
|  "libc", |  | ||||||
|  "pkg-config", |  | ||||||
|  "vcpkg", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "parking" | name = "parking" | ||||||
| version = "2.2.1" | version = "2.2.1" | ||||||
| @ -2601,7 +2483,7 @@ dependencies = [ | |||||||
|  "libc", |  "libc", | ||||||
|  "redox_syscall", |  "redox_syscall", | ||||||
|  "smallvec", |  "smallvec", | ||||||
|  "windows-targets", |  "windows-targets 0.52.6", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -3214,53 +3096,48 @@ dependencies = [ | |||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "reqwest" | name = "reqwest" | ||||||
| version = "0.12.19" | version = "0.12.15" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "a2f8e5513d63f2e5b386eb5106dc67eaf3f84e95258e210489136b8b92ad6119" | checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "base64 0.22.1", |  "base64 0.22.1", | ||||||
|  "bytes", |  "bytes", | ||||||
|  "encoding_rs", |  | ||||||
|  "futures-channel", |  | ||||||
|  "futures-core", |  "futures-core", | ||||||
|  "futures-util", |  "futures-util", | ||||||
|  "h2", |  | ||||||
|  "http", |  "http", | ||||||
|  "http-body", |  "http-body", | ||||||
|  "http-body-util", |  "http-body-util", | ||||||
|  "hyper", |  "hyper", | ||||||
|  "hyper-rustls", |  "hyper-rustls", | ||||||
|  "hyper-tls", |  | ||||||
|  "hyper-util", |  "hyper-util", | ||||||
|  "ipnet", |  "ipnet", | ||||||
|  "js-sys", |  "js-sys", | ||||||
|  "log", |  "log", | ||||||
|  "mime", |  "mime", | ||||||
|  "mime_guess", |  "mime_guess", | ||||||
|  "native-tls", |  | ||||||
|  "once_cell", |  "once_cell", | ||||||
|  "percent-encoding", |  "percent-encoding", | ||||||
|  "pin-project-lite", |  "pin-project-lite", | ||||||
|  "quinn", |  "quinn", | ||||||
|  "rustls", |  "rustls", | ||||||
|  |  "rustls-pemfile", | ||||||
|  "rustls-pki-types", |  "rustls-pki-types", | ||||||
|  "serde", |  "serde", | ||||||
|  "serde_json", |  "serde_json", | ||||||
|  "serde_urlencoded", |  "serde_urlencoded", | ||||||
|  "sync_wrapper", |  "sync_wrapper", | ||||||
|  "tokio", |  "tokio", | ||||||
|  "tokio-native-tls", |  | ||||||
|  "tokio-rustls", |  "tokio-rustls", | ||||||
|  "tokio-util", |  "tokio-util", | ||||||
|  "tower 0.5.2", |  "tower 0.5.2", | ||||||
|  "tower-http", |  | ||||||
|  "tower-service", |  "tower-service", | ||||||
|  "url", |  "url", | ||||||
|  "wasm-bindgen", |  "wasm-bindgen", | ||||||
|  "wasm-bindgen-futures", |  "wasm-bindgen-futures", | ||||||
|  "wasm-streams", |  "wasm-streams", | ||||||
|  "web-sys", |  "web-sys", | ||||||
|  "webpki-roots 1.0.0", |  "webpki-roots", | ||||||
|  |  "windows-registry", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -3524,15 +3401,6 @@ dependencies = [ | |||||||
|  "winapi-util", |  "winapi-util", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "schannel" |  | ||||||
| version = "0.1.27" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" |  | ||||||
| dependencies = [ |  | ||||||
|  "windows-sys 0.59.0", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "scopeguard" | name = "scopeguard" | ||||||
| version = "1.2.0" | version = "1.2.0" | ||||||
| @ -3557,29 +3425,6 @@ version = "4.1.0" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" | checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "security-framework" |  | ||||||
| version = "2.11.1" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" |  | ||||||
| dependencies = [ |  | ||||||
|  "bitflags", |  | ||||||
|  "core-foundation", |  | ||||||
|  "core-foundation-sys", |  | ||||||
|  "libc", |  | ||||||
|  "security-framework-sys", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] |  | ||||||
| name = "security-framework-sys" |  | ||||||
| version = "2.14.0" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" |  | ||||||
| dependencies = [ |  | ||||||
|  "core-foundation-sys", |  | ||||||
|  "libc", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "semver" | name = "semver" | ||||||
| version = "1.0.26" | version = "1.0.26" | ||||||
| @ -3958,7 +3803,6 @@ dependencies = [ | |||||||
|  "log", |  "log", | ||||||
|  "nanoid", |  "nanoid", | ||||||
|  "rand 0.8.5", |  "rand 0.8.5", | ||||||
|  "reqwest", |  | ||||||
|  "serde", |  "serde", | ||||||
|  "serde_json", |  "serde_json", | ||||||
|  "serde_yaml", |  "serde_yaml", | ||||||
| @ -4154,27 +3998,6 @@ dependencies = [ | |||||||
|  "windows", |  "windows", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "system-configuration" |  | ||||||
| version = "0.6.1" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" |  | ||||||
| dependencies = [ |  | ||||||
|  "bitflags", |  | ||||||
|  "core-foundation", |  | ||||||
|  "system-configuration-sys", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] |  | ||||||
| name = "system-configuration-sys" |  | ||||||
| version = "0.6.0" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" |  | ||||||
| dependencies = [ |  | ||||||
|  "core-foundation-sys", |  | ||||||
|  "libc", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "tap" | name = "tap" | ||||||
| version = "1.0.1" | version = "1.0.1" | ||||||
| @ -4369,16 +4192,6 @@ dependencies = [ | |||||||
|  "syn 2.0.100", |  "syn 2.0.100", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "tokio-native-tls" |  | ||||||
| version = "0.3.1" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" |  | ||||||
| dependencies = [ |  | ||||||
|  "native-tls", |  | ||||||
|  "tokio", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "tokio-rustls" | name = "tokio-rustls" | ||||||
| version = "0.26.2" | version = "0.26.2" | ||||||
| @ -4413,7 +4226,7 @@ dependencies = [ | |||||||
|  "tokio", |  "tokio", | ||||||
|  "tokio-rustls", |  "tokio-rustls", | ||||||
|  "tungstenite", |  "tungstenite", | ||||||
|  "webpki-roots 0.26.8", |  "webpki-roots", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -4528,24 +4341,6 @@ dependencies = [ | |||||||
|  "tower-service", |  "tower-service", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "tower-http" |  | ||||||
| version = "0.6.6" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" |  | ||||||
| dependencies = [ |  | ||||||
|  "bitflags", |  | ||||||
|  "bytes", |  | ||||||
|  "futures-util", |  | ||||||
|  "http", |  | ||||||
|  "http-body", |  | ||||||
|  "iri-string", |  | ||||||
|  "pin-project-lite", |  | ||||||
|  "tower 0.5.2", |  | ||||||
|  "tower-layer", |  | ||||||
|  "tower-service", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "tower-layer" | name = "tower-layer" | ||||||
| version = "0.3.3" | version = "0.3.3" | ||||||
| @ -4776,12 +4571,6 @@ version = "0.8.1" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "87782b74f898179396e93c0efabb38de0d58d50bbd47eae00c71b3a1144dbbae" | checksum = "87782b74f898179396e93c0efabb38de0d58d50bbd47eae00c71b3a1144dbbae" | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "vcpkg" |  | ||||||
| version = "0.2.15" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "version_check" | name = "version_check" | ||||||
| version = "0.9.5" | version = "0.9.5" | ||||||
| @ -4954,15 +4743,6 @@ dependencies = [ | |||||||
|  "rustls-pki-types", |  "rustls-pki-types", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] |  | ||||||
| name = "webpki-roots" |  | ||||||
| version = "1.0.0" |  | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" |  | ||||||
| checksum = "2853738d1cc4f2da3a225c18ec6c3721abb31961096e9dbf5ab35fa88b19cfdb" |  | ||||||
| dependencies = [ |  | ||||||
|  "rustls-pki-types", |  | ||||||
| ] |  | ||||||
| 
 |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "winapi" | name = "winapi" | ||||||
| version = "0.3.9" | version = "0.3.9" | ||||||
| @ -5001,7 +4781,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||||||
| checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" | checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "windows-core 0.57.0", |  "windows-core 0.57.0", | ||||||
|  "windows-targets", |  "windows-targets 0.52.6", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -5013,7 +4793,7 @@ dependencies = [ | |||||||
|  "windows-implement 0.57.0", |  "windows-implement 0.57.0", | ||||||
|  "windows-interface 0.57.0", |  "windows-interface 0.57.0", | ||||||
|  "windows-result 0.1.2", |  "windows-result 0.1.2", | ||||||
|  "windows-targets", |  "windows-targets 0.52.6", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -5025,8 +4805,8 @@ dependencies = [ | |||||||
|  "windows-implement 0.60.0", |  "windows-implement 0.60.0", | ||||||
|  "windows-interface 0.59.1", |  "windows-interface 0.59.1", | ||||||
|  "windows-link", |  "windows-link", | ||||||
|  "windows-result 0.3.4", |  "windows-result 0.3.2", | ||||||
|  "windows-strings", |  "windows-strings 0.4.0", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -5081,13 +4861,13 @@ checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" | |||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows-registry" | name = "windows-registry" | ||||||
| version = "0.5.2" | version = "0.4.0" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "b3bab093bdd303a1240bb99b8aba8ea8a69ee19d34c9e2ef9594e708a4878820" | checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "windows-link", |  "windows-result 0.3.2", | ||||||
|  "windows-result 0.3.4", |  "windows-strings 0.3.1", | ||||||
|  "windows-strings", |  "windows-targets 0.53.0", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -5096,23 +4876,32 @@ version = "0.1.2" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" | checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "windows-targets", |  "windows-targets 0.52.6", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows-result" | name = "windows-result" | ||||||
| version = "0.3.4" | version = "0.3.2" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" | checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "windows-link", |  "windows-link", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows-strings" | name = "windows-strings" | ||||||
| version = "0.4.2" | version = "0.3.1" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" | checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" | ||||||
|  | dependencies = [ | ||||||
|  |  "windows-link", | ||||||
|  | ] | ||||||
|  | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows-strings" | ||||||
|  | version = "0.4.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "windows-link", |  "windows-link", | ||||||
| ] | ] | ||||||
| @ -5123,7 +4912,7 @@ version = "0.52.0" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "windows-targets", |  "windows-targets 0.52.6", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -5132,7 +4921,7 @@ version = "0.59.0" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "windows-targets", |  "windows-targets 0.52.6", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -5141,14 +4930,30 @@ version = "0.52.6" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "windows_aarch64_gnullvm", |  "windows_aarch64_gnullvm 0.52.6", | ||||||
|  "windows_aarch64_msvc", |  "windows_aarch64_msvc 0.52.6", | ||||||
|  "windows_i686_gnu", |  "windows_i686_gnu 0.52.6", | ||||||
|  "windows_i686_gnullvm", |  "windows_i686_gnullvm 0.52.6", | ||||||
|  "windows_i686_msvc", |  "windows_i686_msvc 0.52.6", | ||||||
|  "windows_x86_64_gnu", |  "windows_x86_64_gnu 0.52.6", | ||||||
|  "windows_x86_64_gnullvm", |  "windows_x86_64_gnullvm 0.52.6", | ||||||
|  "windows_x86_64_msvc", |  "windows_x86_64_msvc 0.52.6", | ||||||
|  | ] | ||||||
|  | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows-targets" | ||||||
|  | version = "0.53.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" | ||||||
|  | dependencies = [ | ||||||
|  |  "windows_aarch64_gnullvm 0.53.0", | ||||||
|  |  "windows_aarch64_msvc 0.53.0", | ||||||
|  |  "windows_i686_gnu 0.53.0", | ||||||
|  |  "windows_i686_gnullvm 0.53.0", | ||||||
|  |  "windows_i686_msvc 0.53.0", | ||||||
|  |  "windows_x86_64_gnu 0.53.0", | ||||||
|  |  "windows_x86_64_gnullvm 0.53.0", | ||||||
|  |  "windows_x86_64_msvc 0.53.0", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| @ -5157,48 +4962,96 @@ version = "0.52.6" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" | ||||||
| 
 | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows_aarch64_gnullvm" | ||||||
|  | version = "0.53.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" | ||||||
|  | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows_aarch64_msvc" | name = "windows_aarch64_msvc" | ||||||
| version = "0.52.6" | version = "0.52.6" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" | ||||||
| 
 | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows_aarch64_msvc" | ||||||
|  | version = "0.53.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" | ||||||
|  | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows_i686_gnu" | name = "windows_i686_gnu" | ||||||
| version = "0.52.6" | version = "0.52.6" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" | ||||||
| 
 | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows_i686_gnu" | ||||||
|  | version = "0.53.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" | ||||||
|  | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows_i686_gnullvm" | name = "windows_i686_gnullvm" | ||||||
| version = "0.52.6" | version = "0.52.6" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" | ||||||
| 
 | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows_i686_gnullvm" | ||||||
|  | version = "0.53.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" | ||||||
|  | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows_i686_msvc" | name = "windows_i686_msvc" | ||||||
| version = "0.52.6" | version = "0.52.6" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" | ||||||
| 
 | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows_i686_msvc" | ||||||
|  | version = "0.53.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" | ||||||
|  | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows_x86_64_gnu" | name = "windows_x86_64_gnu" | ||||||
| version = "0.52.6" | version = "0.52.6" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" | ||||||
| 
 | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows_x86_64_gnu" | ||||||
|  | version = "0.53.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" | ||||||
|  | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows_x86_64_gnullvm" | name = "windows_x86_64_gnullvm" | ||||||
| version = "0.52.6" | version = "0.52.6" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" | ||||||
| 
 | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows_x86_64_gnullvm" | ||||||
|  | version = "0.53.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" | ||||||
|  | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "windows_x86_64_msvc" | name = "windows_x86_64_msvc" | ||||||
| version = "0.52.6" | version = "0.52.6" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" | ||||||
| 
 | 
 | ||||||
|  | [[package]] | ||||||
|  | name = "windows_x86_64_msvc" | ||||||
|  | version = "0.53.0" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" | ||||||
|  | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "winnow" | name = "winnow" | ||||||
| version = "0.7.6" | version = "0.7.6" | ||||||
|  | |||||||
| @ -40,5 +40,4 @@ ed25519-dalek = { version = "2.1.1", features = ["rand_core"] } | |||||||
| hyper-util = "0.1.11" | hyper-util = "0.1.11" | ||||||
| itertools = "0.14.0" | itertools = "0.14.0" | ||||||
| rand = "0.8" | rand = "0.8" | ||||||
| reqwest = { version = "0.12.19", features = ["blocking"] } |  | ||||||
| tower = "0.5.2" | tower = "0.5.2" | ||||||
|  | |||||||
| @ -1,52 +0,0 @@ | |||||||
| use detee_shared::app_proto::brain_app_cli_server::BrainAppCliServer; |  | ||||||
| use detee_shared::app_proto::brain_app_daemon_server::BrainAppDaemonServer; |  | ||||||
| use detee_shared::general_proto::brain_general_cli_server::BrainGeneralCliServer; |  | ||||||
| use detee_shared::vm_proto::brain_vm_cli_server::BrainVmCliServer; |  | ||||||
| use detee_shared::vm_proto::brain_vm_daemon_server::BrainVmDaemonServer; |  | ||||||
| use dotenv::dotenv; |  | ||||||
| use std::sync::Arc; |  | ||||||
| use surreal_brain::constants::BRAIN_GRPC_ADDR; |  | ||||||
| use surreal_brain::db; |  | ||||||
| use surreal_brain::grpc::app::{AppCliServer, AppDaemonServer}; |  | ||||||
| use surreal_brain::grpc::general::GeneralCliServer; |  | ||||||
| use surreal_brain::grpc::vm::{VmCliServer, VmDaemonServer}; |  | ||||||
| use tonic::transport::Server; |  | ||||||
| 
 |  | ||||||
| #[tokio::main] |  | ||||||
| async fn main() { |  | ||||||
|     if dotenv::from_filename("/etc/detee/brain/config.ini").is_err() { |  | ||||||
|         dotenv().ok(); |  | ||||||
|     } |  | ||||||
|     env_logger::builder() |  | ||||||
|         .filter_level(log::LevelFilter::Trace) |  | ||||||
|         .filter_module("tungstenite", log::LevelFilter::Debug) |  | ||||||
|         .filter_module("tokio_tungstenite", log::LevelFilter::Debug) |  | ||||||
|         .init(); |  | ||||||
| 
 |  | ||||||
|     let db_url = std::env::var("DB_URL").expect("the environment variable DB_URL is not set"); |  | ||||||
|     let db_user = std::env::var("DB_USER").expect("the environment variable DB_USER is not set"); |  | ||||||
|     let db_pass = std::env::var("DB_PASS").expect("the environment variable DB_PASS is not set"); |  | ||||||
|     let db_ns = std::env::var("DB_NAMESPACE").expect("the env variable DB_NAMESPACE is not set"); |  | ||||||
|     let db_name = std::env::var("DB_NAME").expect("the environment variable DB_NAME is not set"); |  | ||||||
| 
 |  | ||||||
|     let db = db::db_connection(&db_url, &db_user, &db_pass, &db_ns, &db_name).await.unwrap(); |  | ||||||
|     let db_arc = Arc::new(db); |  | ||||||
| 
 |  | ||||||
|     let addr = BRAIN_GRPC_ADDR.parse().unwrap(); |  | ||||||
| 
 |  | ||||||
|     let snp_daemon_server = BrainVmDaemonServer::new(VmDaemonServer::new(db_arc.clone())); |  | ||||||
|     let snp_cli_server = BrainVmCliServer::new(VmCliServer::new(db_arc.clone())); |  | ||||||
|     let general_service_server = BrainGeneralCliServer::new(GeneralCliServer::new(db_arc.clone())); |  | ||||||
|     let sgx_daemon_server = BrainAppDaemonServer::new(AppDaemonServer::new(db_arc.clone())); |  | ||||||
|     let sgx_cli_server = BrainAppCliServer::new(AppCliServer::new(db_arc.clone())); |  | ||||||
| 
 |  | ||||||
|     Server::builder() |  | ||||||
|         .add_service(snp_daemon_server) |  | ||||||
|         .add_service(snp_cli_server) |  | ||||||
|         .add_service(general_service_server) |  | ||||||
|         .add_service(sgx_daemon_server) |  | ||||||
|         .add_service(sgx_cli_server) |  | ||||||
|         .serve(addr) |  | ||||||
|         .await |  | ||||||
|         .unwrap(); |  | ||||||
| } |  | ||||||
| @ -225,7 +225,7 @@ impl AppNodeWithReports { | |||||||
|         limit_one: bool, |         limit_one: bool, | ||||||
|     ) -> Result<Vec<Self>, Error> { |     ) -> Result<Vec<Self>, Error> { | ||||||
|         let mut filter_query = format!( |         let mut filter_query = format!( | ||||||
|             "select *, <-report.* as reports from {APP_NODE} where
 |             "select *, <-report.* from {APP_NODE} where
 | ||||||
|             avail_ports >= {} && |             avail_ports >= {} && | ||||||
|             max_ports_per_app >= {} && |             max_ports_per_app >= {} && | ||||||
|             avail_vcpus >= {} && |             avail_vcpus >= {} && | ||||||
| @ -238,7 +238,6 @@ impl AppNodeWithReports { | |||||||
|             filters.storage_gb |             filters.storage_gb | ||||||
|         ); |         ); | ||||||
| 
 | 
 | ||||||
|         // TODO: bind all strings
 |  | ||||||
|         if !filters.city.is_empty() { |         if !filters.city.is_empty() { | ||||||
|             filter_query += &format!("&& city = '{}' ", filters.city); |             filter_query += &format!("&& city = '{}' ", filters.city); | ||||||
|         } |         } | ||||||
| @ -594,10 +593,10 @@ impl ActiveAppWithNode { | |||||||
| 
 | 
 | ||||||
| #[derive(Debug, Serialize)] | #[derive(Debug, Serialize)] | ||||||
| pub struct AppNodeResources { | pub struct AppNodeResources { | ||||||
|     pub avail_ports: u32, |     pub avail_no_of_port: u32, | ||||||
|     pub avail_vcpus: u32, |     pub avail_vcpus: u32, | ||||||
|     pub avail_mem_mb: u32, |     pub avail_memory_mb: u32, | ||||||
|     pub avail_storage_gbs: u32, |     pub avail_storage_gb: u32, | ||||||
|     pub max_ports_per_app: u32, |     pub max_ports_per_app: u32, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -608,7 +607,6 @@ impl AppNodeResources { | |||||||
|         node_pubkey: &str, |         node_pubkey: &str, | ||||||
|     ) -> Result<Option<AppNode>, Error> { |     ) -> Result<Option<AppNode>, Error> { | ||||||
|         let app_node: Option<AppNode> = db.update((APP_NODE, node_pubkey)).merge(self).await?; |         let app_node: Option<AppNode> = db.update((APP_NODE, node_pubkey)).merge(self).await?; | ||||||
|         log::trace!("Merged app node resources for {node_pubkey}: {:?}", app_node); |  | ||||||
|         Ok(app_node) |         Ok(app_node) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -700,7 +698,6 @@ pub struct DeletedApp { | |||||||
| 
 | 
 | ||||||
| impl DeletedApp { | impl DeletedApp { | ||||||
|     pub async fn list_by_node(db: &Surreal<Client>, node_pubkey: &str) -> Result<Vec<Self>, Error> { |     pub async fn list_by_node(db: &Surreal<Client>, node_pubkey: &str) -> Result<Vec<Self>, Error> { | ||||||
|         // TODO: bind all strings
 |  | ||||||
|         let mut result = db |         let mut result = db | ||||||
|             .query(format!("select * from {DELETED_APP} where out = {APP_NODE}:{node_pubkey};")) |             .query(format!("select * from {DELETED_APP} where out = {APP_NODE}:{node_pubkey};")) | ||||||
|             .await?; |             .await?; | ||||||
|  | |||||||
| @ -173,8 +173,6 @@ pub async fn live_appnode_msgs< | |||||||
|             return Err(Error::UnknownTable(t.to_string())); |             return Err(Error::UnknownTable(t.to_string())); | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
|     log::trace!("live_appnode_msgs for {table_name} DB stream for node {node_pubkey}"); |  | ||||||
|     // TODO: bind node_pubkey
 |  | ||||||
|     let mut query_resp = db |     let mut query_resp = db | ||||||
|         .query(format!("live select * from {table_name} where out = {APP_NODE}:{node_pubkey};")) |         .query(format!("live select * from {table_name} where out = {APP_NODE}:{node_pubkey};")) | ||||||
|         .await?; |         .await?; | ||||||
|  | |||||||
| @ -141,7 +141,6 @@ impl BrainAppDaemon for AppDaemonServer { | |||||||
|             match daemon_message { |             match daemon_message { | ||||||
|                 Ok(msg) => match msg.msg { |                 Ok(msg) => match msg.msg { | ||||||
|                     Some(daemon_message_app::Msg::NewAppRes(new_app_resp)) => { |                     Some(daemon_message_app::Msg::NewAppRes(new_app_resp)) => { | ||||||
|                         log::trace!("New app response from node: {pubkey}, {:?}", new_app_resp); |  | ||||||
|                         if !new_app_resp.error.is_empty() { |                         if !new_app_resp.error.is_empty() { | ||||||
|                             db::NewAppReq::submit_error( |                             db::NewAppReq::submit_error( | ||||||
|                                 &self.db, |                                 &self.db, | ||||||
| @ -155,7 +154,6 @@ impl BrainAppDaemon for AppDaemonServer { | |||||||
|                     } |                     } | ||||||
|                     Some(daemon_message_app::Msg::AppNodeResources(app_node_resources)) => { |                     Some(daemon_message_app::Msg::AppNodeResources(app_node_resources)) => { | ||||||
|                         let node_resource: db::AppNodeResources = app_node_resources.into(); |                         let node_resource: db::AppNodeResources = app_node_resources.into(); | ||||||
|                         log::trace!("App node {pubkey} resources: {:?}", node_resource); |  | ||||||
|                         node_resource.merge(&self.db, &pubkey).await?; |                         node_resource.merge(&self.db, &pubkey).await?; | ||||||
|                     } |                     } | ||||||
|                     _ => {} |                     _ => {} | ||||||
|  | |||||||
| @ -375,10 +375,10 @@ impl From<db::AppDaemonMsg> for BrainMessageApp { | |||||||
| impl From<AppNodeResources> for db::AppNodeResources { | impl From<AppNodeResources> for db::AppNodeResources { | ||||||
|     fn from(value: AppNodeResources) -> Self { |     fn from(value: AppNodeResources) -> Self { | ||||||
|         Self { |         Self { | ||||||
|             avail_ports: value.avail_no_of_port, |             avail_no_of_port: value.avail_no_of_port, | ||||||
|             avail_vcpus: value.avail_vcpus, |             avail_vcpus: value.avail_vcpus, | ||||||
|             avail_mem_mb: value.avail_memory_mb, |             avail_memory_mb: value.avail_memory_mb, | ||||||
|             avail_storage_gbs: value.avail_storage_gb, |             avail_storage_gb: value.avail_storage_gb, | ||||||
|             max_ports_per_app: value.max_ports_per_app, |             max_ports_per_app: value.max_ports_per_app, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,7 +1,5 @@ | |||||||
| // SPDX-License-Identifier: Apache-2.0
 | // SPDX-License-Identifier: Apache-2.0
 | ||||||
| 
 | 
 | ||||||
| use super::test_utils::Key; |  | ||||||
| use crate::common::test_utils::{generate_random_public_ip, get_ip_info}; |  | ||||||
| use anyhow::Result; | use anyhow::Result; | ||||||
| use detee_shared::app_proto::brain_app_daemon_client::BrainAppDaemonClient; | use detee_shared::app_proto::brain_app_daemon_client::BrainAppDaemonClient; | ||||||
| use detee_shared::app_proto::{self, NewAppRes, RegisterAppNodeReq}; | use detee_shared::app_proto::{self, NewAppRes, RegisterAppNodeReq}; | ||||||
| @ -11,6 +9,8 @@ use tokio::sync::mpsc; | |||||||
| use tokio_stream::wrappers::ReceiverStream; | use tokio_stream::wrappers::ReceiverStream; | ||||||
| use tonic::transport::Channel; | use tonic::transport::Channel; | ||||||
| 
 | 
 | ||||||
|  | use super::test_utils::Key; | ||||||
|  | 
 | ||||||
| pub async fn mock_app_daemon( | pub async fn mock_app_daemon( | ||||||
|     brain_channel: &Channel, |     brain_channel: &Channel, | ||||||
|     daemon_error: Option<String>, |     daemon_error: Option<String>, | ||||||
| @ -47,16 +47,13 @@ pub async fn register_app_node( | |||||||
|     log::info!("Registering app_node: {}", key.pubkey); |     log::info!("Registering app_node: {}", key.pubkey); | ||||||
|     let node_pubkey = key.pubkey.clone(); |     let node_pubkey = key.pubkey.clone(); | ||||||
| 
 | 
 | ||||||
|     let ip = generate_random_public_ip().to_string(); |  | ||||||
|     let ip_info = get_ip_info(&ip).await?; |  | ||||||
| 
 |  | ||||||
|     let req = RegisterAppNodeReq { |     let req = RegisterAppNodeReq { | ||||||
|         node_pubkey, |         node_pubkey, | ||||||
|         operator_wallet: operator_wallet.to_string(), |         operator_wallet: operator_wallet.to_string(), | ||||||
|         main_ip: ip_info.ip, |         main_ip: String::from("185.243.218.213"), | ||||||
|         city: ip_info.city, |         city: String::from("Oslo"), | ||||||
|         country: ip_info.country, |         country: String::from("Norway"), | ||||||
|         region: ip_info.region, |         region: String::from("EU"), | ||||||
|         price: 1200, |         price: 1200, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| @ -139,7 +136,7 @@ pub async fn daemon_engine( | |||||||
|                 tx.send(res).await?; |                 tx.send(res).await?; | ||||||
|             } |             } | ||||||
|             Some(app_proto::brain_message_app::Msg::DeleteAppReq(del_app_req)) => { |             Some(app_proto::brain_message_app::Msg::DeleteAppReq(del_app_req)) => { | ||||||
|                 println!("MOCK_APP_DAEMON::delete app request for {}", del_app_req.uuid); |                 println!("MOCK_APP_DAEMON:: delete app request for {}", del_app_req.uuid); | ||||||
|             } |             } | ||||||
|             None => todo!(), |             None => todo!(), | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -8,6 +8,7 @@ use detee_shared::vm_proto::brain_vm_cli_server::BrainVmCliServer; | |||||||
| use detee_shared::vm_proto::brain_vm_daemon_server::BrainVmDaemonServer; | use detee_shared::vm_proto::brain_vm_daemon_server::BrainVmDaemonServer; | ||||||
| use dotenv::dotenv; | use dotenv::dotenv; | ||||||
| use hyper_util::rt::TokioIo; | use hyper_util::rt::TokioIo; | ||||||
|  | use std::net::SocketAddr; | ||||||
| use std::sync::Arc; | use std::sync::Arc; | ||||||
| use surreal_brain::constants::DB_SCHEMA_FILES; | use surreal_brain::constants::DB_SCHEMA_FILES; | ||||||
| use surreal_brain::grpc::app::{AppCliServer, AppDaemonServer}; | use surreal_brain::grpc::app::{AppCliServer, AppDaemonServer}; | ||||||
| @ -16,8 +17,9 @@ use surreal_brain::grpc::vm::{VmCliServer, VmDaemonServer}; | |||||||
| use surrealdb::engine::remote::ws::Client; | use surrealdb::engine::remote::ws::Client; | ||||||
| use surrealdb::Surreal; | use surrealdb::Surreal; | ||||||
| use tokio::io::DuplexStream; | use tokio::io::DuplexStream; | ||||||
|  | use tokio::net::TcpListener; | ||||||
| use tokio::sync::OnceCell; | use tokio::sync::OnceCell; | ||||||
| use tonic::transport::{Channel, Endpoint, Uri}; | use tonic::transport::{Channel, Endpoint, Server, Uri}; | ||||||
| use tower::service_fn; | use tower::service_fn; | ||||||
| 
 | 
 | ||||||
| pub static DB_STATE: OnceCell<Result<()>> = OnceCell::const_new(); | pub static DB_STATE: OnceCell<Result<()>> = OnceCell::const_new(); | ||||||
| @ -29,7 +31,7 @@ pub async fn prepare_test_db() -> Result<Surreal<Client>> { | |||||||
|     let db_user = std::env::var("DB_USER").expect("DB_USER not set in .env"); |     let db_user = std::env::var("DB_USER").expect("DB_USER not set in .env"); | ||||||
|     let db_pass = std::env::var("DB_PASS").expect("DB_PASS not set in .env"); |     let db_pass = std::env::var("DB_PASS").expect("DB_PASS not set in .env"); | ||||||
|     let db_ns = "test_brain"; |     let db_ns = "test_brain"; | ||||||
|     let db_name = "test_brain_db"; |     let db_name = "test_migration_db"; | ||||||
| 
 | 
 | ||||||
|     let db = surreal_brain::db::db_connection(&db_url, &db_user, &db_pass, db_ns, db_name).await?; |     let db = surreal_brain::db::db_connection(&db_url, &db_user, &db_pass, db_ns, db_name).await?; | ||||||
|     DB_STATE |     DB_STATE | ||||||
| @ -49,6 +51,37 @@ pub async fn prepare_test_db() -> Result<Surreal<Client>> { | |||||||
|     Ok(db) |     Ok(db) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | pub async fn run_service_in_background() -> Result<SocketAddr> { | ||||||
|  |     dotenv().ok(); | ||||||
|  |     let listener = TcpListener::bind("127.0.0.1:0").await?; | ||||||
|  |     let addr = listener.local_addr()?; | ||||||
|  | 
 | ||||||
|  |     let db_url = std::env::var("DB_URL").expect("DB_URL not set in .env"); | ||||||
|  |     let db_user = std::env::var("DB_USER").expect("DB_USER not set in .env"); | ||||||
|  |     let db_pass = std::env::var("DB_PASS").expect("DB_PASS not set in .env"); | ||||||
|  |     let db_ns = "test_brain"; | ||||||
|  |     let db_name = "test_migration_db"; | ||||||
|  | 
 | ||||||
|  |     tokio::spawn(async move { | ||||||
|  |         let db = | ||||||
|  |             surreal_brain::db::db_connection(&db_url, &db_user, &db_pass, db_ns, db_name).await?; | ||||||
|  |         let db_arc = Arc::new(db); | ||||||
|  | 
 | ||||||
|  |         Server::builder() | ||||||
|  |             .add_service(BrainGeneralCliServer::new(GeneralCliServer::new(db_arc.clone()))) | ||||||
|  |             .add_service(BrainVmCliServer::new(VmCliServer::new(db_arc.clone()))) | ||||||
|  |             .add_service(BrainVmDaemonServer::new(VmDaemonServer::new(db_arc.clone()))) | ||||||
|  |             .serve_with_incoming(tokio_stream::wrappers::TcpListenerStream::new(listener)) | ||||||
|  |             .await?; | ||||||
|  | 
 | ||||||
|  |         Ok::<(), anyhow::Error>(()) | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     tokio::time::sleep(tokio::time::Duration::from_millis(300)).await; | ||||||
|  | 
 | ||||||
|  |     Ok(addr) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| pub async fn run_service_for_stream_server() -> DuplexStream { | pub async fn run_service_for_stream_server() -> DuplexStream { | ||||||
|     dotenv().ok(); |     dotenv().ok(); | ||||||
|     let (client, server) = tokio::io::duplex(1024); |     let (client, server) = tokio::io::duplex(1024); | ||||||
| @ -57,7 +90,7 @@ pub async fn run_service_for_stream_server() -> DuplexStream { | |||||||
|     let db_user = std::env::var("DB_USER").expect("DB_USER not set in .env"); |     let db_user = std::env::var("DB_USER").expect("DB_USER not set in .env"); | ||||||
|     let db_pass = std::env::var("DB_PASS").expect("DB_PASS not set in .env"); |     let db_pass = std::env::var("DB_PASS").expect("DB_PASS not set in .env"); | ||||||
|     let db_ns = "test_brain"; |     let db_ns = "test_brain"; | ||||||
|     let db_name = "test_brain_db"; |     let db_name = "test_migration_db"; | ||||||
| 
 | 
 | ||||||
|     tokio::spawn(async move { |     tokio::spawn(async move { | ||||||
|         let db = |         let db = | ||||||
|  | |||||||
| @ -7,8 +7,6 @@ use detee_shared::general_proto::AirdropReq; | |||||||
| use detee_shared::vm_proto as snp_proto; | use detee_shared::vm_proto as snp_proto; | ||||||
| use ed25519_dalek::{Signer, SigningKey}; | use ed25519_dalek::{Signer, SigningKey}; | ||||||
| use itertools::Itertools; | use itertools::Itertools; | ||||||
| use rand::Rng; |  | ||||||
| use std::net::Ipv4Addr; |  | ||||||
| use std::sync::OnceLock; | use std::sync::OnceLock; | ||||||
| use surreal_brain::constants::TOKEN_DECIMAL; | use surreal_brain::constants::TOKEN_DECIMAL; | ||||||
| use tonic::metadata::AsciiMetadataValue; | use tonic::metadata::AsciiMetadataValue; | ||||||
| @ -102,35 +100,3 @@ pub async fn airdrop(brain_channel: &Channel, wallet: &str, amount: u64) -> Resu | |||||||
| 
 | 
 | ||||||
|     Ok(()) |     Ok(()) | ||||||
| } | } | ||||||
| 
 |  | ||||||
| pub async fn get_ip_info(ip: &str) -> anyhow::Result<IPInfo> { |  | ||||||
|     let body = reqwest::get(format!("https://ipinfo.io/{ip}")).await?.text().await?; |  | ||||||
|     log::info!("Got the following data from ipinfo.io: {body}"); |  | ||||||
|     Ok(serde_json::de::from_str(&body)?) |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #[derive(serde::Deserialize, Clone, Debug)] |  | ||||||
| pub struct IPInfo { |  | ||||||
|     pub country: String, |  | ||||||
|     pub region: String, |  | ||||||
|     pub city: String, |  | ||||||
|     pub ip: String, |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| pub fn generate_random_public_ip() -> Ipv4Addr { |  | ||||||
|     let mut rng = rand::thread_rng(); |  | ||||||
|     loop { |  | ||||||
|         let ip = Ipv4Addr::from(rng.gen::<u32>()); |  | ||||||
|         if !ip.is_private() |  | ||||||
|             && !ip.is_loopback() |  | ||||||
|             && !ip.is_link_local() |  | ||||||
|             && !ip.is_broadcast() |  | ||||||
|             && !ip.is_documentation() |  | ||||||
|             && !ip.is_unspecified() |  | ||||||
|             && !ip.is_multicast() |  | ||||||
|             && ip.octets()[0] < 240 |  | ||||||
|         { |  | ||||||
|             return ip; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  | |||||||
| @ -1,7 +1,6 @@ | |||||||
| // SPDX-License-Identifier: Apache-2.0
 | // SPDX-License-Identifier: Apache-2.0
 | ||||||
| 
 | 
 | ||||||
| use super::test_utils::Key; | use super::test_utils::Key; | ||||||
| use crate::common::test_utils::{generate_random_public_ip, get_ip_info}; |  | ||||||
| use anyhow::Result; | use anyhow::Result; | ||||||
| use detee_shared::vm_proto; | use detee_shared::vm_proto; | ||||||
| use detee_shared::vm_proto::brain_vm_daemon_client::BrainVmDaemonClient; | use detee_shared::vm_proto::brain_vm_daemon_client::BrainVmDaemonClient; | ||||||
| @ -47,16 +46,13 @@ pub async fn register_vm_node( | |||||||
|     log::info!("Registering vm_node: {}", key.pubkey); |     log::info!("Registering vm_node: {}", key.pubkey); | ||||||
|     let node_pubkey = key.pubkey.clone(); |     let node_pubkey = key.pubkey.clone(); | ||||||
| 
 | 
 | ||||||
|     let ip = generate_random_public_ip().to_string(); |  | ||||||
|     let ip_info = get_ip_info(&ip).await?; |  | ||||||
| 
 |  | ||||||
|     let req = RegisterVmNodeReq { |     let req = RegisterVmNodeReq { | ||||||
|         node_pubkey, |         node_pubkey, | ||||||
|         operator_wallet: operator_wallet.to_string(), |         operator_wallet: operator_wallet.to_string(), | ||||||
|         main_ip: ip_info.ip, |         main_ip: String::from("185.243.218.213"), | ||||||
|         city: ip_info.city, |         city: String::from("Oslo"), | ||||||
|         country: ip_info.country, |         country: String::from("Norway"), | ||||||
|         region: ip_info.region, |         region: String::from("EU"), | ||||||
|         price: 1200, |         price: 1200, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| @ -143,7 +139,7 @@ pub async fn daemon_engine( | |||||||
|                 todo!() |                 todo!() | ||||||
|             } |             } | ||||||
|             Some(vm_proto::brain_vm_message::Msg::DeleteVm(del_vm_req)) => { |             Some(vm_proto::brain_vm_message::Msg::DeleteVm(del_vm_req)) => { | ||||||
|                 println!("MOCK_VM_DAEMON::delete vm request for {}", del_vm_req.uuid); |                 println!("MOCK_VM_DAEMON:: delete vm request for {}", del_vm_req.uuid); | ||||||
|             } |             } | ||||||
|             None => todo!(), |             None => todo!(), | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -4,17 +4,12 @@ use common::app_daemon_utils::mock_app_daemon; | |||||||
| use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; | use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; | ||||||
| use common::test_utils::{airdrop, Key}; | use common::test_utils::{airdrop, Key}; | ||||||
| use detee_shared::app_proto::brain_app_cli_client::BrainAppCliClient; | use detee_shared::app_proto::brain_app_cli_client::BrainAppCliClient; | ||||||
| use detee_shared::app_proto::brain_app_daemon_client::BrainAppDaemonClient; | use detee_shared::app_proto::{self, DelAppReq}; | ||||||
| use detee_shared::app_proto::{self, AppNodeFilters, DelAppReq}; |  | ||||||
| use std::vec; | use std::vec; | ||||||
| use surreal_brain::constants::{ | use surreal_brain::constants::{ACCOUNT, ACTIVE_APP, DELETED_APP, NEW_APP_REQ, TOKEN_DECIMAL}; | ||||||
|     ACCOUNT, ACTIVE_APP, APP_NODE, DELETED_APP, NEW_APP_REQ, TOKEN_DECIMAL, |  | ||||||
| }; |  | ||||||
| use surreal_brain::db::app::AppNode; |  | ||||||
| use surreal_brain::db::prelude as db; | use surreal_brain::db::prelude as db; | ||||||
| 
 | 
 | ||||||
| use crate::common::app_cli_utils::create_new_app; | use crate::common::app_cli_utils::create_new_app; | ||||||
| use crate::common::app_daemon_utils::register_app_node; |  | ||||||
| 
 | 
 | ||||||
| mod common; | mod common; | ||||||
| 
 | 
 | ||||||
| @ -102,16 +97,13 @@ async fn test_app_creation() { | |||||||
| async fn test_timeout_app_creation() { | async fn test_timeout_app_creation() { | ||||||
|     let _ = prepare_test_db().await.unwrap(); |     let _ = prepare_test_db().await.unwrap(); | ||||||
|     let brain_channel = run_service_for_stream().await.unwrap(); |     let brain_channel = run_service_for_stream().await.unwrap(); | ||||||
|     let daemon_key = Key::new(); |     let daemon_key = Key::new().pubkey.clone(); | ||||||
| 
 | 
 | ||||||
|     let key = Key::new(); |     let key = Key::new(); | ||||||
| 
 | 
 | ||||||
|     let mut daemon_client = BrainAppDaemonClient::new(brain_channel.clone()); |  | ||||||
|     register_app_node(&mut daemon_client, &daemon_key, &Key::new().pubkey).await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let new_app_req = app_proto::NewAppReq { |     let new_app_req = app_proto::NewAppReq { | ||||||
|         admin_pubkey: key.pubkey.clone(), |         admin_pubkey: key.pubkey.clone(), | ||||||
|         node_pubkey: daemon_key.pubkey.clone(), |         node_pubkey: daemon_key.clone(), | ||||||
|         price_per_unit: 1200, |         price_per_unit: 1200, | ||||||
|         resource: Some(app_proto::AppResource { ports: vec![8080, 8081], ..Default::default() }), |         resource: Some(app_proto::AppResource { ports: vec![8080, 8081], ..Default::default() }), | ||||||
|         locked_nano: 100, |         locked_nano: 100, | ||||||
| @ -189,38 +181,4 @@ async fn test_app_deletion() { | |||||||
|     assert!(deleted_app.is_some()); |     assert!(deleted_app.is_some()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[tokio::test] |  | ||||||
| async fn test_get_one_app_node() { |  | ||||||
|     let db = prepare_test_db().await.unwrap(); |  | ||||||
|     let brain_channel = run_service_for_stream().await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let mut client_app_cli = BrainAppCliClient::new(brain_channel.clone()); |  | ||||||
|     let key = Key::new(); |  | ||||||
| 
 |  | ||||||
|     let mut req = AppNodeFilters { ..Default::default() }; |  | ||||||
| 
 |  | ||||||
|     let mock_app_node = client_app_cli |  | ||||||
|         .get_one_app_node(key.sign_request(req.clone()).unwrap()) |  | ||||||
|         .await |  | ||||||
|         .unwrap() |  | ||||||
|         .into_inner(); |  | ||||||
| 
 |  | ||||||
|     assert_eq!( |  | ||||||
|         mock_app_node.node_pubkey, |  | ||||||
|         "BiqoPUEoAxYxMRXUmyofoS9H1TBQgQqvLJ6MbWh88AQg".to_string() |  | ||||||
|     ); |  | ||||||
| 
 |  | ||||||
|     let node_pubkey = mock_app_daemon(&brain_channel, None).await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let new_node_ip = |  | ||||||
|         db.select::<Option<AppNode>>((APP_NODE, node_pubkey.clone())).await.unwrap().unwrap().ip; |  | ||||||
| 
 |  | ||||||
|     req.ip = new_node_ip; |  | ||||||
| 
 |  | ||||||
|     let new_app_node = |  | ||||||
|         client_app_cli.get_one_app_node(key.sign_request(req).unwrap()).await.unwrap().into_inner(); |  | ||||||
| 
 |  | ||||||
|     assert_eq!(new_app_node.node_pubkey, node_pubkey); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // TODO: test register app node, delete app contract while node offline, kick, etc..
 | // TODO: test register app node, delete app contract while node offline, kick, etc..
 | ||||||
|  | |||||||
| @ -1,139 +0,0 @@ | |||||||
| use common::app_daemon_utils::{mock_app_daemon, register_app_node}; |  | ||||||
| use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; |  | ||||||
| use common::test_utils::{airdrop, Key}; |  | ||||||
| use detee_shared::app_proto::brain_app_cli_client::BrainAppCliClient; |  | ||||||
| use detee_shared::app_proto::brain_app_daemon_client::BrainAppDaemonClient; |  | ||||||
| use detee_shared::app_proto::{self, AppNodeResources}; |  | ||||||
| use surreal_brain::constants::APP_NODE; |  | ||||||
| use surreal_brain::db::app::AppNode; |  | ||||||
| use surreal_brain::db::prelude as db; |  | ||||||
| use tokio_stream::wrappers::ReceiverStream; |  | ||||||
| 
 |  | ||||||
| mod common; |  | ||||||
| 
 |  | ||||||
| // TODO: test app registration and resource handling
 |  | ||||||
| 
 |  | ||||||
| #[tokio::test] |  | ||||||
| async fn test_reg_app_node() { |  | ||||||
|     let db = prepare_test_db().await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let channel = run_service_for_stream().await.unwrap(); |  | ||||||
|     let mut client = BrainAppDaemonClient::new(channel); |  | ||||||
| 
 |  | ||||||
|     let node_key = Key::new(); |  | ||||||
| 
 |  | ||||||
|     let del_app_req = register_app_node(&mut client, &node_key, &Key::new().pubkey).await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     assert!(del_app_req.is_empty()); |  | ||||||
| 
 |  | ||||||
|     let app_node: Option<db::AppNode> = db.select((APP_NODE, node_key.pubkey)).await.unwrap(); |  | ||||||
|     assert!(app_node.is_some()); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #[tokio::test] |  | ||||||
| async fn test_brain_message() { |  | ||||||
|     env_logger::builder().filter_level(log::LevelFilter::Error).init(); |  | ||||||
|     let _ = prepare_test_db().await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let brain_channel = run_service_for_stream().await.unwrap(); |  | ||||||
|     let daemon_key = mock_app_daemon(&brain_channel, None).await.unwrap(); |  | ||||||
|     let mut cli_client = BrainAppCliClient::new(brain_channel.clone()); |  | ||||||
| 
 |  | ||||||
|     let cli_key = Key::new(); |  | ||||||
| 
 |  | ||||||
|     let req = app_proto::NewAppReq { |  | ||||||
|         admin_pubkey: cli_key.pubkey.clone(), |  | ||||||
|         node_pubkey: daemon_key, |  | ||||||
|         price_per_unit: 1200, |  | ||||||
|         // extra_ports: vec![8080, 8081],
 |  | ||||||
|         locked_nano: 100, |  | ||||||
|         ..Default::default() |  | ||||||
|     }; |  | ||||||
|     airdrop(&brain_channel, &cli_key.pubkey, 10).await.unwrap(); |  | ||||||
|     let new_app_resp = |  | ||||||
|         cli_client.new_app(cli_key.sign_request(req).unwrap()).await.unwrap().into_inner(); |  | ||||||
| 
 |  | ||||||
|     assert!(new_app_resp.error.is_empty()); |  | ||||||
|     assert!(new_app_resp.uuid.len() == 40); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #[tokio::test] |  | ||||||
| async fn test_app_daemon_resource_msg() { |  | ||||||
|     /* |  | ||||||
|     env_logger::builder() |  | ||||||
|         .filter_level(log::LevelFilter::Trace) |  | ||||||
|         .filter_module("tungstenite", log::LevelFilter::Debug) |  | ||||||
|         .filter_module("tokio_tungstenite", log::LevelFilter::Debug) |  | ||||||
|         .init(); |  | ||||||
|     */ |  | ||||||
| 
 |  | ||||||
|     let db = prepare_test_db().await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let brain_channel = run_service_for_stream().await.unwrap(); |  | ||||||
|     let mut daemon_client = BrainAppDaemonClient::new(brain_channel); |  | ||||||
| 
 |  | ||||||
|     let daemon_key = Key::new(); |  | ||||||
| 
 |  | ||||||
|     register_app_node(&mut daemon_client, &daemon_key, &Key::new().pubkey).await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let (tx, rx) = tokio::sync::mpsc::channel(32); |  | ||||||
| 
 |  | ||||||
|     let tx_01 = tx.clone(); |  | ||||||
|     let daemon_key_01 = daemon_key.clone(); |  | ||||||
| 
 |  | ||||||
|     tokio::spawn(async move { |  | ||||||
|         tx_01 |  | ||||||
|             .send(app_proto::DaemonMessageApp { |  | ||||||
|                 msg: Some(app_proto::daemon_message_app::Msg::Auth( |  | ||||||
|                     daemon_key_01.clone().sign_stream_auth_app(vec![]).unwrap(), |  | ||||||
|                 )), |  | ||||||
|             }) |  | ||||||
|             .await |  | ||||||
|             .unwrap(); |  | ||||||
| 
 |  | ||||||
|         let rx_stream = ReceiverStream::new(rx); |  | ||||||
|         daemon_client.daemon_messages(rx_stream).await.unwrap(); |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     let tx_02 = tx.clone(); |  | ||||||
|     let daemon_pubkey = daemon_key.clone().pubkey; |  | ||||||
| 
 |  | ||||||
|     let req_data = AppNodeResources { |  | ||||||
|         node_pubkey: daemon_pubkey, |  | ||||||
|         avail_no_of_port: 5, |  | ||||||
|         avail_vcpus: 4, |  | ||||||
|         avail_memory_mb: 8192, |  | ||||||
|         avail_storage_gb: 100, |  | ||||||
|         max_ports_per_app: 5, |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     let req_data_copy = req_data.clone(); |  | ||||||
| 
 |  | ||||||
|     tokio::spawn(async move { |  | ||||||
|         tx_02 |  | ||||||
|             .send(app_proto::DaemonMessageApp { |  | ||||||
|                 msg: Some(app_proto::daemon_message_app::Msg::AppNodeResources(req_data_copy)), |  | ||||||
|             }) |  | ||||||
|             .await |  | ||||||
|             .unwrap(); |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; |  | ||||||
| 
 |  | ||||||
|     let app_node_opt: Option<AppNode> = db.select((APP_NODE, daemon_key.pubkey)).await.unwrap(); |  | ||||||
|     assert!(app_node_opt.is_some()); |  | ||||||
|     let db::AppNode { |  | ||||||
|         avail_mem_mb, |  | ||||||
|         avail_vcpus, |  | ||||||
|         avail_storage_gbs, |  | ||||||
|         avail_ports, |  | ||||||
|         max_ports_per_app, |  | ||||||
|         .. |  | ||||||
|     } = app_node_opt.unwrap(); |  | ||||||
| 
 |  | ||||||
|     assert_eq!(avail_mem_mb, req_data.avail_memory_mb); |  | ||||||
|     assert_eq!(avail_vcpus, req_data.avail_vcpus); |  | ||||||
|     assert_eq!(avail_storage_gbs, req_data.avail_storage_gb); |  | ||||||
|     assert_eq!(avail_ports, req_data.avail_no_of_port); |  | ||||||
|     assert_eq!(max_ports_per_app, req_data.max_ports_per_app); |  | ||||||
| } |  | ||||||
| @ -1,6 +1,8 @@ | |||||||
| // SPDX-License-Identifier: Apache-2.0
 | // SPDX-License-Identifier: Apache-2.0
 | ||||||
| 
 | 
 | ||||||
| use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; | use common::prepare_test_env::{ | ||||||
|  |     prepare_test_db, run_service_for_stream, run_service_in_background, | ||||||
|  | }; | ||||||
| use common::test_utils::{admin_keys, airdrop, Key}; | use common::test_utils::{admin_keys, airdrop, Key}; | ||||||
| use common::vm_cli_utils::{ | use common::vm_cli_utils::{ | ||||||
|     create_new_vm, list_accounts, list_all_app_contracts, list_all_vm_contracts, register_operator, |     create_new_vm, list_accounts, list_all_app_contracts, list_all_vm_contracts, register_operator, | ||||||
| @ -29,8 +31,8 @@ async fn test_general_balance() { | |||||||
|      */ |      */ | ||||||
|     prepare_test_db().await.unwrap(); |     prepare_test_db().await.unwrap(); | ||||||
| 
 | 
 | ||||||
|     let channel = run_service_for_stream().await.unwrap(); |     let addr = run_service_in_background().await.unwrap(); | ||||||
|     let mut client = BrainGeneralCliClient::new(channel); |     let mut client = BrainGeneralCliClient::connect(format!("http://{}", addr)).await.unwrap(); | ||||||
| 
 | 
 | ||||||
|     let key = Key::new(); |     let key = Key::new(); | ||||||
|     let pubkey = key.pubkey.clone(); |     let pubkey = key.pubkey.clone(); | ||||||
| @ -51,8 +53,8 @@ async fn test_general_airdrop() { | |||||||
| 
 | 
 | ||||||
|     let airdrop_amount = 10; |     let airdrop_amount = 10; | ||||||
| 
 | 
 | ||||||
|     let channel = run_service_for_stream().await.unwrap(); |     let addr = run_service_in_background().await.unwrap(); | ||||||
|     let mut client = BrainGeneralCliClient::new(channel); |     let mut client = BrainGeneralCliClient::connect(format!("http://{}", addr)).await.unwrap(); | ||||||
| 
 | 
 | ||||||
|     let admin_keys = admin_keys(); |     let admin_keys = admin_keys(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -7,13 +7,9 @@ use common::vm_daemon_utils::{mock_vm_daemon, register_vm_node}; | |||||||
| use detee_shared::vm_proto; | use detee_shared::vm_proto; | ||||||
| use detee_shared::vm_proto::brain_vm_cli_client::BrainVmCliClient; | use detee_shared::vm_proto::brain_vm_cli_client::BrainVmCliClient; | ||||||
| use detee_shared::vm_proto::brain_vm_daemon_client::BrainVmDaemonClient; | use detee_shared::vm_proto::brain_vm_daemon_client::BrainVmDaemonClient; | ||||||
| use detee_shared::vm_proto::{ | use detee_shared::vm_proto::{DeleteVmReq, ExtendVmReq, ListVmContractsReq, NewVmReq}; | ||||||
|     DeleteVmReq, ExtendVmReq, ListVmContractsReq, NewVmReq, VmNodeFilters, |  | ||||||
| }; |  | ||||||
| use futures::StreamExt; | use futures::StreamExt; | ||||||
| use surreal_brain::constants::{ | use surreal_brain::constants::{ACCOUNT, ACTIVE_VM, DELETED_VM, NEW_VM_REQ, TOKEN_DECIMAL}; | ||||||
|     ACCOUNT, ACTIVE_VM, DELETED_VM, NEW_VM_REQ, TOKEN_DECIMAL, VM_NODE, |  | ||||||
| }; |  | ||||||
| use surreal_brain::db::prelude as db; | use surreal_brain::db::prelude as db; | ||||||
| 
 | 
 | ||||||
| mod common; | mod common; | ||||||
| @ -305,42 +301,4 @@ async fn test_extend_vm() { | |||||||
|     assert_eq!(acc.balance, expected_bal_02); |     assert_eq!(acc.balance, expected_bal_02); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[tokio::test] |  | ||||||
| async fn test_get_one_vm_node() { |  | ||||||
|     let db = prepare_test_db().await.unwrap(); |  | ||||||
|     let brain_channel = run_service_for_stream().await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let mut client_vm_cli = BrainVmCliClient::new(brain_channel.clone()); |  | ||||||
|     let key = Key::new(); |  | ||||||
| 
 |  | ||||||
|     let mut req = VmNodeFilters::default(); |  | ||||||
| 
 |  | ||||||
|     let mock_vm_node = client_vm_cli |  | ||||||
|         .get_one_vm_node(key.sign_request(req.clone()).unwrap()) |  | ||||||
|         .await |  | ||||||
|         .unwrap() |  | ||||||
|         .into_inner(); |  | ||||||
| 
 |  | ||||||
|     let mock_data_vm_nodes = [ |  | ||||||
|         "2Uf5pxhxKTUm6gRMnpbJHYDuyA6BWUfFsdmPyWfbMV1f", |  | ||||||
|         "3zRxiGRnf46vd3zAEmpaYBJocTV9oJB6yXf5GZFR1Sq4", |  | ||||||
|         "7Xw3RxbP5pvfjZ8U6yA3HHVSS9YXjKH5Vkas3JRbQYd9", |  | ||||||
|         "DgkbsrwttkZXvzxY5kDwQQoDd79GLmZ5tc7fYJUFkQQb", |  | ||||||
|         "Du3UfPSUUZmA5thQmc9Vrxdy7UimpygcpDsQNnwRQPtu", |  | ||||||
|         "HiyMp21zaBVbRCjDsD5hEjQnHeHv4e1gpUR6pVfHTKqv", |  | ||||||
|     ]; |  | ||||||
|     assert!(mock_data_vm_nodes.contains(&mock_vm_node.node_pubkey.as_str())); |  | ||||||
| 
 |  | ||||||
|     let node_pubkey = mock_vm_daemon(&brain_channel, None).await.unwrap(); |  | ||||||
|     let new_node_ip = |  | ||||||
|         db.select::<Option<db::VmNode>>((VM_NODE, node_pubkey.clone())).await.unwrap().unwrap().ip; |  | ||||||
| 
 |  | ||||||
|     req.ip = new_node_ip; |  | ||||||
| 
 |  | ||||||
|     let new_app_node = |  | ||||||
|         client_vm_cli.get_one_vm_node(key.sign_request(req).unwrap()).await.unwrap().into_inner(); |  | ||||||
| 
 |  | ||||||
|     assert_eq!(new_app_node.node_pubkey, node_pubkey); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // TODO: test register vm node, delete vm contract while node offline, kick, etc..
 | // TODO: test register vm node, delete vm contract while node offline, kick, etc..
 | ||||||
|  | |||||||
| @ -1,14 +1,13 @@ | |||||||
| // SPDX-License-Identifier: Apache-2.0
 | // SPDX-License-Identifier: Apache-2.0
 | ||||||
| 
 | 
 | ||||||
| use crate::common::test_utils::{airdrop, Key}; | use common::prepare_test_env::{ | ||||||
| use common::prepare_test_env::{prepare_test_db, run_service_for_stream}; |     prepare_test_db, run_service_for_stream, run_service_in_background, | ||||||
|  | }; | ||||||
|  | use common::test_utils::{airdrop, Key}; | ||||||
| use common::vm_daemon_utils::{mock_vm_daemon, register_vm_node}; | use common::vm_daemon_utils::{mock_vm_daemon, register_vm_node}; | ||||||
| use detee_shared::vm_proto; | use detee_shared::vm_proto; | ||||||
| use detee_shared::vm_proto::brain_vm_cli_client::BrainVmCliClient; | use detee_shared::vm_proto::brain_vm_cli_client::BrainVmCliClient; | ||||||
| use detee_shared::vm_proto::brain_vm_daemon_client::BrainVmDaemonClient; | use detee_shared::vm_proto::brain_vm_daemon_client::BrainVmDaemonClient; | ||||||
| use surreal_brain::constants::VM_NODE; |  | ||||||
| use surreal_brain::db::prelude as db; |  | ||||||
| use tokio_stream::wrappers::ReceiverStream; |  | ||||||
| 
 | 
 | ||||||
| mod common; | mod common; | ||||||
| 
 | 
 | ||||||
| @ -16,12 +15,13 @@ mod common; | |||||||
| async fn test_reg_vm_node() { | async fn test_reg_vm_node() { | ||||||
|     prepare_test_db().await.unwrap(); |     prepare_test_db().await.unwrap(); | ||||||
| 
 | 
 | ||||||
|     let channel = run_service_for_stream().await.unwrap(); |     let addr = run_service_in_background().await.unwrap(); | ||||||
|     let mut client = BrainVmDaemonClient::new(channel); |     let mut client = BrainVmDaemonClient::connect(format!("http://{}", addr)).await.unwrap(); | ||||||
| 
 | 
 | ||||||
|     let del_vm_reqs = register_vm_node(&mut client, &Key::new(), &Key::new().pubkey).await.unwrap(); |     let vm_contracts = | ||||||
|  |         register_vm_node(&mut client, &Key::new(), &Key::new().pubkey).await.unwrap(); | ||||||
| 
 | 
 | ||||||
|     assert!(del_vm_reqs.is_empty()) |     assert!(vm_contracts.is_empty()) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[tokio::test] | #[tokio::test] | ||||||
| @ -52,83 +52,3 @@ async fn test_brain_message() { | |||||||
|     assert!(new_vm_resp.args.is_some()); |     assert!(new_vm_resp.args.is_some()); | ||||||
|     assert!(new_vm_resp.args.unwrap().exposed_ports.len() == 3); |     assert!(new_vm_resp.args.unwrap().exposed_ports.len() == 3); | ||||||
| } | } | ||||||
| #[tokio::test] |  | ||||||
| async fn test_vm_daemon_resource_msg() { |  | ||||||
|     let db = prepare_test_db().await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let brain_channel = run_service_for_stream().await.unwrap(); |  | ||||||
|     let mut daemon_client = BrainVmDaemonClient::new(brain_channel); |  | ||||||
| 
 |  | ||||||
|     let daemon_key = Key::new(); |  | ||||||
| 
 |  | ||||||
|     register_vm_node(&mut daemon_client, &daemon_key, &Key::new().pubkey).await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     let (tx, rx) = tokio::sync::mpsc::channel(32); |  | ||||||
| 
 |  | ||||||
|     let tx_01 = tx.clone(); |  | ||||||
|     let daemon_key_01 = daemon_key.clone(); |  | ||||||
| 
 |  | ||||||
|     tokio::spawn(async move { |  | ||||||
|         tx_01 |  | ||||||
|             .send(vm_proto::VmDaemonMessage { |  | ||||||
|                 msg: Some(vm_proto::vm_daemon_message::Msg::Auth( |  | ||||||
|                     daemon_key_01.clone().sign_stream_auth_vm(vec![]).unwrap(), |  | ||||||
|                 )), |  | ||||||
|             }) |  | ||||||
|             .await |  | ||||||
|             .unwrap(); |  | ||||||
| 
 |  | ||||||
|         let rx_stream = ReceiverStream::new(rx); |  | ||||||
|         daemon_client.daemon_messages(rx_stream).await.unwrap(); |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     let tx_02 = tx.clone(); |  | ||||||
|     let daemon_pubkey = daemon_key.clone().pubkey; |  | ||||||
| 
 |  | ||||||
|     let req_data = vm_proto::VmNodeResources { |  | ||||||
|         node_pubkey: daemon_pubkey, |  | ||||||
|         avail_ports: 5, |  | ||||||
|         avail_ipv4: 2, |  | ||||||
|         avail_ipv6: 88, |  | ||||||
|         avail_vcpus: 4, |  | ||||||
|         avail_memory_mb: 8192, |  | ||||||
|         avail_storage_gb: 100, |  | ||||||
|         max_ports_per_vm: 5, |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     let req_data_copy = req_data.clone(); |  | ||||||
| 
 |  | ||||||
|     tokio::spawn(async move { |  | ||||||
|         tx_02 |  | ||||||
|             .send(vm_proto::VmDaemonMessage { |  | ||||||
|                 msg: Some(vm_proto::vm_daemon_message::Msg::VmNodeResources(req_data_copy)), |  | ||||||
|             }) |  | ||||||
|             .await |  | ||||||
|             .unwrap(); |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     tokio::time::sleep(tokio::time::Duration::from_millis(300)).await; |  | ||||||
| 
 |  | ||||||
|     let vm_node_opt: Option<db::VmNode> = db.select((VM_NODE, daemon_key.pubkey)).await.unwrap(); |  | ||||||
| 
 |  | ||||||
|     assert!(vm_node_opt.is_some()); |  | ||||||
| 
 |  | ||||||
|     let db::VmNode { |  | ||||||
|         avail_mem_mb, |  | ||||||
|         avail_vcpus, |  | ||||||
|         avail_storage_gbs, |  | ||||||
|         avail_ports, |  | ||||||
|         avail_ipv4, |  | ||||||
|         avail_ipv6, |  | ||||||
|         max_ports_per_vm, |  | ||||||
|         .. |  | ||||||
|     } = vm_node_opt.unwrap(); |  | ||||||
| 
 |  | ||||||
|     assert_eq!(avail_mem_mb, req_data.avail_memory_mb); |  | ||||||
|     assert_eq!(avail_vcpus, req_data.avail_vcpus); |  | ||||||
|     assert_eq!(avail_storage_gbs, req_data.avail_storage_gb); |  | ||||||
|     assert_eq!(avail_ports, req_data.avail_ports); |  | ||||||
|     assert_eq!(avail_ipv4, req_data.avail_ipv4); |  | ||||||
|     assert_eq!(avail_ipv6, req_data.avail_ipv6); |  | ||||||
|     assert_eq!(max_ports_per_vm, req_data.max_ports_per_vm); |  | ||||||
| } |  | ||||||
|  | |||||||
| @ -302,7 +302,7 @@ vm_nodes: | |||||||
|     max_ports_per_vm: 10 |     max_ports_per_vm: 10 | ||||||
|     price: 24000 |     price: 24000 | ||||||
|     reports: {} |     reports: {} | ||||||
|     offline_minutes: 1 |     offline_minutes: 0 | ||||||
| 
 | 
 | ||||||
| vm_contracts: | vm_contracts: | ||||||
|   - uuid: 958165e3-dea8-407d-8c42-dd17002ef79c |   - uuid: 958165e3-dea8-407d-8c42-dd17002ef79c | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user