Add program-test tests to bpf programs (#16407)
This commit is contained in:
parent
6cd4bc5e60
commit
476fd40948
|
@ -79,7 +79,6 @@ _ ci/do-audit.sh
|
|||
cd "$project"
|
||||
_ "$cargo" nightly clippy -- --deny=warnings --allow=clippy::missing_safety_doc
|
||||
_ "$cargo" stable fmt -- --check
|
||||
_ "$cargo" nightly test
|
||||
)
|
||||
done
|
||||
}
|
||||
|
|
|
@ -43,6 +43,14 @@ test-stable-perf)
|
|||
# BPF solana-sdk legacy compile test
|
||||
./cargo-build-bpf --manifest-path sdk/Cargo.toml
|
||||
|
||||
# BPF Program unit tests
|
||||
for program in programs/bpf/rust/*; do
|
||||
if [ -d "${program}" ]; then
|
||||
_ "$cargo" test --manifest-path "$program"/Cargo.toml
|
||||
_ "$cargo" test-bpf --manifest-path "$program"/Cargo.toml --bpf-sdk sdk/bpf
|
||||
fi
|
||||
done
|
||||
|
||||
# BPF program tests
|
||||
_ make -C programs/bpf/c tests
|
||||
_ "$cargo" stable test \
|
||||
|
|
|
@ -79,6 +79,17 @@ version = "1.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "695579f0f2520f3774bb40461e5adb066459d4e0af4d59d20175484fb8e9edf1"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
|
@ -222,7 +233,7 @@ dependencies = [
|
|||
"borsh-schema-derive-internal",
|
||||
"proc-macro-crate",
|
||||
"proc-macro2 1.0.24",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -233,7 +244,7 @@ checksum = "d813fa25eb0bed78c36492cff4415f38c760d6de833d255ba9095bd8ebb7d725"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -244,7 +255,7 @@ checksum = "dcf78ee4a98c8cb9eba1bac3d3e2a1ea3d7673c719ce691e67b5cbafc472d3b7"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -367,6 +378,15 @@ dependencies = [
|
|||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chrono-humanize"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8164ae3089baf04ff71f32aeb70213283dcd236dce8bc976d00b17a458f5f71c"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.3"
|
||||
|
@ -665,7 +685,7 @@ checksum = "eaed5874effa6cde088c644ddcdcb4ffd1511391c5be4fdd7a5ccd02c7e4a183"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -758,6 +778,18 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "educe"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54ed56329d95e524ef98177ad672881bdfe7f22f254eb6ae80deb6fdd2ab20c4"
|
||||
dependencies = [
|
||||
"enum-ordinalize",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.5.3"
|
||||
|
@ -788,6 +820,19 @@ dependencies = [
|
|||
"cfg-if 0.1.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enum-ordinalize"
|
||||
version = "3.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d52ff39419d3e16961ecfb9e32f5042bdaacf9a4cc553d2d688057117bae49b"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.8.3"
|
||||
|
@ -953,7 +998,7 @@ dependencies = [
|
|||
"proc-macro-hack",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1080,7 +1125,7 @@ dependencies = [
|
|||
"http",
|
||||
"indexmap",
|
||||
"slab",
|
||||
"tokio 1.1.1",
|
||||
"tokio 1.4.0",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
]
|
||||
|
@ -1227,7 +1272,7 @@ dependencies = [
|
|||
"itoa",
|
||||
"pin-project",
|
||||
"socket2",
|
||||
"tokio 1.1.1",
|
||||
"tokio 1.4.0",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"want",
|
||||
|
@ -1243,7 +1288,7 @@ dependencies = [
|
|||
"hyper",
|
||||
"log",
|
||||
"rustls",
|
||||
"tokio 1.1.1",
|
||||
"tokio 1.4.0",
|
||||
"tokio-rustls",
|
||||
"webpki",
|
||||
]
|
||||
|
@ -1665,6 +1710,17 @@ dependencies = [
|
|||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d0a3d5e207573f948a9e5376662aa743a2ea13f7c50a554d7af443a73fbfeba"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-derive"
|
||||
version = "0.2.5"
|
||||
|
@ -1684,7 +1740,7 @@ checksum = "0c8b15b261814f992e33760b1fca9fe8b693d8a65299f20c9901688636cfb746"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1735,7 +1791,7 @@ dependencies = [
|
|||
"proc-macro-crate",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1823,7 +1879,7 @@ dependencies = [
|
|||
"Inflector",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1970,7 +2026,7 @@ checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2260,7 +2316,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"tokio 1.1.1",
|
||||
"tokio 1.4.0",
|
||||
"tokio-rustls",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
|
@ -2383,7 +2439,7 @@ checksum = "e367622f934864ffa1c704ba2b82280aab856e3d8213c84c5720257eb34b15b9"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2478,7 +2534,7 @@ checksum = "8dee1f300f838c8ac340ecb0112b3ac472464fa67e87292bdb3dfc9c49128e17"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2635,6 +2691,51 @@ dependencies = [
|
|||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-banks-client"
|
||||
version = "1.7.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"borsh",
|
||||
"borsh-derive",
|
||||
"futures 0.3.12",
|
||||
"mio 0.7.7",
|
||||
"solana-banks-interface",
|
||||
"solana-program 1.7.0",
|
||||
"solana-sdk",
|
||||
"tarpc",
|
||||
"tokio 1.4.0",
|
||||
"tokio-serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-banks-interface"
|
||||
version = "1.7.0"
|
||||
dependencies = [
|
||||
"mio 0.7.7",
|
||||
"serde",
|
||||
"solana-sdk",
|
||||
"tarpc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-banks-server"
|
||||
version = "1.7.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"futures 0.3.12",
|
||||
"log",
|
||||
"mio 0.7.7",
|
||||
"solana-banks-interface",
|
||||
"solana-metrics",
|
||||
"solana-runtime",
|
||||
"solana-sdk",
|
||||
"tarpc",
|
||||
"tokio 1.4.0",
|
||||
"tokio-serde",
|
||||
"tokio-stream",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-bpf-loader-program"
|
||||
version = "1.7.0"
|
||||
|
@ -2922,6 +3023,8 @@ name = "solana-bpf-rust-sysvar"
|
|||
version = "1.7.0"
|
||||
dependencies = [
|
||||
"solana-program 1.7.0",
|
||||
"solana-program-test",
|
||||
"solana-sdk",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3014,7 +3117,7 @@ dependencies = [
|
|||
"solana-version",
|
||||
"solana-vote-program",
|
||||
"thiserror",
|
||||
"tokio 1.1.1",
|
||||
"tokio 1.4.0",
|
||||
"tungstenite",
|
||||
"url",
|
||||
]
|
||||
|
@ -3049,7 +3152,7 @@ dependencies = [
|
|||
"reqwest",
|
||||
"serde",
|
||||
"syn 0.15.44",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
"tokio 0.1.22",
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
@ -3072,7 +3175,7 @@ dependencies = [
|
|||
"solana-version",
|
||||
"spl-memo",
|
||||
"thiserror",
|
||||
"tokio 1.1.1",
|
||||
"tokio 1.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3123,7 +3226,7 @@ dependencies = [
|
|||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"rustc_version",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3134,7 +3237,7 @@ dependencies = [
|
|||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"rustc_version",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3195,7 +3298,7 @@ dependencies = [
|
|||
"solana-clap-utils",
|
||||
"solana-logger 1.7.0",
|
||||
"solana-version",
|
||||
"tokio 1.1.1",
|
||||
"tokio 1.4.0",
|
||||
"url",
|
||||
]
|
||||
|
||||
|
@ -3261,6 +3364,27 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-program-test"
|
||||
version = "1.7.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.12.3",
|
||||
"chrono",
|
||||
"chrono-humanize",
|
||||
"log",
|
||||
"mio 0.7.7",
|
||||
"solana-banks-client",
|
||||
"solana-banks-server",
|
||||
"solana-bpf-loader-program",
|
||||
"solana-logger 1.7.0",
|
||||
"solana-runtime",
|
||||
"solana-sdk",
|
||||
"solana-vote-program",
|
||||
"thiserror",
|
||||
"tokio 1.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-rayon-threadlimit"
|
||||
version = "1.7.0"
|
||||
|
@ -3388,7 +3512,7 @@ dependencies = [
|
|||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"rustversion",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3399,7 +3523,7 @@ dependencies = [
|
|||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"rustversion",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3554,6 +3678,12 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
|
@ -3591,9 +3721,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.60"
|
||||
version = "1.0.67"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
|
||||
checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
|
@ -3608,7 +3738,7 @@ checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
"unicode-xid 0.2.0",
|
||||
]
|
||||
|
||||
|
@ -3624,6 +3754,38 @@ dependencies = [
|
|||
"xattr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tarpc"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e325774dd5b35d979e9f4db2b0f0d7d85dc2ff2b676a3150af56c09eafc14b07"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"fnv",
|
||||
"futures 0.3.12",
|
||||
"humantime",
|
||||
"log",
|
||||
"pin-project",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"static_assertions",
|
||||
"tarpc-plugins",
|
||||
"tokio 1.4.0",
|
||||
"tokio-serde",
|
||||
"tokio-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tarpc-plugins"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3240378a22b1195734e085ba71d1d4188d50f034aea82635acc430b7005afb5"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.2.0"
|
||||
|
@ -3692,7 +3854,7 @@ checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3773,9 +3935,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.1.1"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6714d663090b6b0acb0fa85841c6d66233d150cdb2602c8f9b8abb03370beb3f"
|
||||
checksum = "134af885d758d645f0f0505c9a8b3f9bf8a348fd822e112ab5248138348f1722"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"bytes 1.0.1",
|
||||
|
@ -3846,13 +4008,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42517d2975ca3114b22a16192634e8241dc5cc1f130be194645970cc1c371494"
|
||||
checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3881,10 +4043,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
|
||||
dependencies = [
|
||||
"rustls",
|
||||
"tokio 1.1.1",
|
||||
"tokio 1.4.0",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-serde"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "911a61637386b789af998ee23f50aa30d5fd7edcec8d6d3dedae5e5815205466"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bytes 1.0.1",
|
||||
"educe",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"pin-project",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-stream"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e177a5d8c3bf36de9ebe6d58537d8879e964332f93fb3339e43f618c81361af0"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"pin-project-lite 0.2.4",
|
||||
"tokio 1.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-sync"
|
||||
version = "0.1.8"
|
||||
|
@ -3982,7 +4171,7 @@ dependencies = [
|
|||
"futures-sink",
|
||||
"log",
|
||||
"pin-project-lite 0.2.4",
|
||||
"tokio 1.1.1",
|
||||
"tokio 1.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4207,7 +4396,7 @@ dependencies = [
|
|||
"log",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
|
@ -4241,7 +4430,7 @@ checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
@ -4378,7 +4567,7 @@ checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2"
|
|||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.60",
|
||||
"syn 1.0.67",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ fn main() {
|
|||
"sha256",
|
||||
"spoof1",
|
||||
"spoof1_system",
|
||||
"sysvar",
|
||||
"upgradeable",
|
||||
"upgraded",
|
||||
];
|
||||
|
|
|
@ -12,8 +12,12 @@ edition = "2018"
|
|||
[dependencies]
|
||||
solana-program = { path = "../../../../sdk/program", version = "=1.7.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
solana-program-test = { path = "../../../../program-test", version = "=1.7.0" }
|
||||
solana-sdk = { path = "../../../../sdk", version = "=1.7.0" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
|
|
@ -3,62 +3,79 @@
|
|||
extern crate solana_program;
|
||||
use solana_program::{
|
||||
account_info::AccountInfo,
|
||||
clock::DEFAULT_SLOTS_PER_EPOCH,
|
||||
entrypoint,
|
||||
entrypoint::ProgramResult,
|
||||
fee_calculator::FeeCalculator,
|
||||
msg,
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
rent,
|
||||
sysvar::{
|
||||
self, clock::Clock, fees::Fees, instructions, rent::Rent, slot_hashes::SlotHashes,
|
||||
self, clock::Clock, epoch_schedule::EpochSchedule, fees::Fees, instructions,
|
||||
recent_blockhashes::RecentBlockhashes, rent::Rent, slot_hashes::SlotHashes,
|
||||
slot_history::SlotHistory, stake_history::StakeHistory, Sysvar,
|
||||
},
|
||||
};
|
||||
|
||||
entrypoint!(process_instruction);
|
||||
#[allow(clippy::unnecessary_wraps)]
|
||||
fn process_instruction(
|
||||
pub fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &[AccountInfo],
|
||||
_instruction_data: &[u8],
|
||||
) -> ProgramResult {
|
||||
// Clock
|
||||
{
|
||||
msg!("Clock identifier:");
|
||||
sysvar::clock::id().log();
|
||||
let clock = Clock::from_account_info(&accounts[2]).unwrap();
|
||||
assert_eq!(clock.slot, DEFAULT_SLOTS_PER_EPOCH + 1);
|
||||
assert_ne!(clock, Clock::default());
|
||||
}
|
||||
|
||||
// Epoch Schedule
|
||||
{
|
||||
msg!("EpochSchedule identifier:");
|
||||
sysvar::epoch_schedule::id().log();
|
||||
let epoch_schedule = EpochSchedule::from_account_info(&accounts[3]).unwrap();
|
||||
assert_eq!(epoch_schedule, EpochSchedule::default());
|
||||
}
|
||||
|
||||
// Fees
|
||||
{
|
||||
msg!("Fees identifier:");
|
||||
sysvar::fees::id().log();
|
||||
let fees = Fees::from_account_info(&accounts[3]).unwrap();
|
||||
let fees = Fees::from_account_info(&accounts[4]).unwrap();
|
||||
let fee_calculator = fees.fee_calculator;
|
||||
assert_eq!(fee_calculator.lamports_per_signature, 0);
|
||||
assert_ne!(fee_calculator, FeeCalculator::default());
|
||||
}
|
||||
|
||||
// Instructions
|
||||
msg!("Instructions identifier:");
|
||||
sysvar::instructions::id().log();
|
||||
let index = instructions::load_current_index(&accounts[4].try_borrow_data()?);
|
||||
let index = instructions::load_current_index(&accounts[5].try_borrow_data()?);
|
||||
assert_eq!(0, index);
|
||||
msg!(
|
||||
"instruction {:?}",
|
||||
instructions::load_instruction_at(index as usize, &accounts[4].try_borrow_data()?)
|
||||
);
|
||||
|
||||
let due = Rent::from_account_info(&accounts[5]).unwrap().due(
|
||||
rent::DEFAULT_LAMPORTS_PER_BYTE_YEAR * rent::DEFAULT_EXEMPTION_THRESHOLD as u64,
|
||||
1,
|
||||
1.0,
|
||||
);
|
||||
assert_eq!(due, (0, true));
|
||||
// Recent Blockhashes
|
||||
{
|
||||
msg!("RecentBlockhashes identifier:");
|
||||
sysvar::recent_blockhashes::id().log();
|
||||
let recent_blockhashes = RecentBlockhashes::from_account_info(&accounts[6]).unwrap();
|
||||
assert_ne!(recent_blockhashes, RecentBlockhashes::default());
|
||||
}
|
||||
|
||||
// Rent
|
||||
{
|
||||
msg!("Rent identifier:");
|
||||
sysvar::rent::id().log();
|
||||
let rent = Rent::from_account_info(&accounts[7]).unwrap();
|
||||
assert_eq!(rent, Rent::default());
|
||||
}
|
||||
|
||||
// Slot Hashes
|
||||
msg!("SlotHashes identifier:");
|
||||
sysvar::slot_hashes::id().log();
|
||||
assert_eq!(
|
||||
Err(ProgramError::UnsupportedSysvar),
|
||||
SlotHashes::from_account_info(&accounts[6])
|
||||
SlotHashes::from_account_info(&accounts[8])
|
||||
);
|
||||
|
||||
// Slot History
|
||||
|
@ -66,14 +83,13 @@ fn process_instruction(
|
|||
sysvar::slot_history::id().log();
|
||||
assert_eq!(
|
||||
Err(ProgramError::UnsupportedSysvar),
|
||||
SlotHistory::from_account_info(&accounts[7])
|
||||
SlotHistory::from_account_info(&accounts[9])
|
||||
);
|
||||
|
||||
// Stake History
|
||||
msg!("StakeHistory identifier:");
|
||||
sysvar::stake_history::id().log();
|
||||
let stake_history = StakeHistory::from_account_info(&accounts[8]).unwrap();
|
||||
assert!(stake_history.len() >= 1);
|
||||
let _ = StakeHistory::from_account_info(&accounts[10]).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
use solana_bpf_rust_sysvar::process_instruction;
|
||||
use solana_program_test::*;
|
||||
use solana_sdk::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
pubkey::Pubkey,
|
||||
signature::Signer,
|
||||
sysvar::{
|
||||
clock, epoch_schedule, fees, instructions, recent_blockhashes, rent, slot_hashes,
|
||||
slot_history, stake_history,
|
||||
},
|
||||
transaction::Transaction,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_noop() {
|
||||
let program_id = Pubkey::new_unique();
|
||||
let program_test = ProgramTest::new(
|
||||
"solana_bpf_rust_sysvar",
|
||||
program_id,
|
||||
processor!(process_instruction),
|
||||
);
|
||||
let (mut banks_client, payer, recent_blockhash) = program_test.start().await;
|
||||
|
||||
let mut transaction = Transaction::new_with_payer(
|
||||
&[Instruction::new_with_bincode(
|
||||
program_id,
|
||||
&(),
|
||||
vec![
|
||||
AccountMeta::new(payer.pubkey(), true),
|
||||
AccountMeta::new(Pubkey::new_unique(), false),
|
||||
AccountMeta::new_readonly(clock::id(), false),
|
||||
AccountMeta::new_readonly(epoch_schedule::id(), false),
|
||||
AccountMeta::new_readonly(fees::id(), false),
|
||||
AccountMeta::new_readonly(instructions::id(), false),
|
||||
AccountMeta::new_readonly(recent_blockhashes::id(), false),
|
||||
AccountMeta::new_readonly(rent::id(), false),
|
||||
AccountMeta::new_readonly(slot_hashes::id(), false),
|
||||
AccountMeta::new_readonly(slot_history::id(), false),
|
||||
AccountMeta::new_readonly(stake_history::id(), false),
|
||||
],
|
||||
)],
|
||||
Some(&payer.pubkey()),
|
||||
);
|
||||
transaction.sign(&[&payer], recent_blockhash);
|
||||
banks_client.process_transaction(transaction).await.unwrap();
|
||||
}
|
|
@ -25,7 +25,7 @@ use solana_sdk::{
|
|||
account::{AccountSharedData, ReadableAccount},
|
||||
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
|
||||
client::SyncClient,
|
||||
clock::{DEFAULT_SLOTS_PER_EPOCH, MAX_PROCESSING_AGE},
|
||||
clock::MAX_PROCESSING_AGE,
|
||||
entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
|
||||
feature_set::ristretto_mul_syscall_enabled,
|
||||
instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError},
|
||||
|
@ -35,7 +35,7 @@ use solana_sdk::{
|
|||
pubkey::Pubkey,
|
||||
signature::{keypair_from_seed, Keypair, Signer},
|
||||
system_instruction,
|
||||
sysvar::{clock, fees, rent, slot_hashes, slot_history, stake_history, instructions},
|
||||
sysvar::{clock, fees, rent},
|
||||
transaction::{Transaction, TransactionError},
|
||||
};
|
||||
use solana_transaction_status::{
|
||||
|
@ -438,7 +438,6 @@ fn test_program_bpf_sanity() {
|
|||
("solana_bpf_rust_ristretto", true),
|
||||
("solana_bpf_rust_sanity", true),
|
||||
("solana_bpf_rust_sha256", true),
|
||||
("solana_bpf_rust_sysvar", true),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -450,13 +449,10 @@ fn test_program_bpf_sanity() {
|
|||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_config(50);
|
||||
|
||||
let mut bank = Bank::new(&genesis_config);
|
||||
let (name, id, entrypoint) = solana_bpf_loader_program!();
|
||||
bank.add_builtin(&name, id, entrypoint);
|
||||
let bank = Arc::new(bank);
|
||||
|
||||
// Create bank with a specific slot, used by solana_bpf_rust_sysvar test
|
||||
let bank = Bank::new_from_parent(&bank, &Pubkey::default(), DEFAULT_SLOTS_PER_EPOCH + 1);
|
||||
let bank_client = BankClient::new(bank);
|
||||
|
||||
// Call user program
|
||||
|
@ -465,14 +461,6 @@ fn test_program_bpf_sanity() {
|
|||
let account_metas = vec![
|
||||
AccountMeta::new(mint_keypair.pubkey(), true),
|
||||
AccountMeta::new(Keypair::new().pubkey(), false),
|
||||
AccountMeta::new_readonly(clock::id(), false),
|
||||
AccountMeta::new_readonly(fees::id(), false),
|
||||
AccountMeta::new_readonly(instructions::id(), false),
|
||||
AccountMeta::new_readonly(rent::id(), false),
|
||||
AccountMeta::new_readonly(slot_hashes::id(), false),
|
||||
AccountMeta::new_readonly(slot_history::id(), false),
|
||||
AccountMeta::new_readonly(stake_history::id(), false),
|
||||
|
||||
];
|
||||
let instruction = Instruction::new_with_bytes(program_id, &[1], account_metas);
|
||||
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction);
|
||||
|
|
|
@ -22,7 +22,11 @@ pub fn load_program<T: Client>(
|
|||
let instruction = system_instruction::create_account(
|
||||
&from_keypair.pubkey(),
|
||||
&program_pubkey,
|
||||
1,
|
||||
1.max(
|
||||
bank_client
|
||||
.get_minimum_balance_for_rent_exemption(program.len())
|
||||
.unwrap(),
|
||||
),
|
||||
program.len() as u64,
|
||||
loader_pubkey,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue