Commit 8fb9eca8 authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'fix-rm-balance' into 'dev'

[fix] gva: revert: rm balance if wallet had received its first money

See merge request nodes/typescript/duniter!1365
parents 4da37489 939e92d8
......@@ -1046,9 +1046,9 @@ checksum = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d"
[[package]]
name = "dubp"
version = "0.49.0"
version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9617091ba0d0a0cc95392655b0b7136fee3b63101d64c0fd0a5c2741983f18"
checksum = "1669c61ccfe0d3fc7be8fe3175ebd401b9c879f638425f31e92777c73b32ea86"
dependencies = [
"dubp-block",
"dubp-common",
......@@ -1060,9 +1060,9 @@ dependencies = [
[[package]]
name = "dubp-block"
version = "0.49.0"
version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53a15b5320e575d8549a549e1950c08a166531d1edf687da4d98fecb00d5bdf7"
checksum = "c602ecf3e703abf6492b5bb66fbd9ad658f974407a7d7d13651f6a1a26122028"
dependencies = [
"dubp-documents",
"dubp-documents-parser",
......@@ -1075,9 +1075,9 @@ dependencies = [
[[package]]
name = "dubp-common"
version = "0.49.0"
version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da764b34a61ecb52fa90dc11f5a44d6bc9599b043d37592b5102b95d993fd677"
checksum = "515fb09166a50b4543a99c42359fc4afa5a4c7af118c6f9627575c2760f3fef8"
dependencies = [
"dup-crypto",
"serde",
......@@ -1088,9 +1088,9 @@ dependencies = [
[[package]]
name = "dubp-documents"
version = "0.49.0"
version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8810039b6dd6a101109aebc9836ddec58366052803f824c56016889d9444f5cf"
checksum = "ccc9327c62778ee4fd060c0efbe32c6cfda5e317c4a2eb4ddee8293fbd278904"
dependencies = [
"beef",
"dubp-wallet",
......@@ -1102,9 +1102,9 @@ dependencies = [
[[package]]
name = "dubp-documents-parser"
version = "0.49.0"
version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c791c77a3f9c670666dc41f861481cc80eb1ad193584727adfee792350fd3129"
checksum = "271ce4a6bebfdfdaefb0e51f57c9bb04976fce5fbe2744dd60c1dcf857c60c20"
dependencies = [
"dubp-documents",
"json-pest-parser",
......@@ -1116,9 +1116,9 @@ dependencies = [
[[package]]
name = "dubp-wallet"
version = "0.49.0"
version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ef8e7c5334ddbc7899f83911026ebc324ba7fc7232c7ca5265e611490dbd282"
checksum = "f6e65a121fa6745038e903ed3d1eb6a97f9658c6c6e2bfbf7e9ffdaf34161d23"
dependencies = [
"byteorder",
"dubp-common",
......@@ -1475,9 +1475,9 @@ dependencies = [
[[package]]
name = "dup-crypto"
version = "0.49.0"
version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0be04829b31b18bacf5317001366d807e5fbd02085ee6348508c1299b5bcaf6c"
checksum = "3032421000ca2cdd372bd72f4c548be7f1386d357abb0936291890064d3072e8"
dependencies = [
"aes",
"arrayvec",
......
......@@ -17,7 +17,7 @@ neon-build = "0.4.0"
[dependencies]
bincode = "1.2.1"
bs58 = "0.3.0"
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
dubp-wot = { path = "../../rust-libs/dubp-wot" }
duniter-server = { path = "../../rust-libs/duniter-server" }
flate2 = "1.0.16"
......
......@@ -22,7 +22,7 @@ anyhow = "1.0.33"
arrayvec = "0.5.1"
comfy-table = "2.1.0"
dirs = "3.0.1"
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
duniter-dbs = { path = "../../rust-libs/duniter-dbs", default-features = false, features = ["explorer", "leveldb_backend", "sled_backend"] }
duniter-dbs-write-ops = { path = "../../rust-libs/duniter-dbs-write-ops", default-features = false, features = ["explorer", "leveldb_backend", "sled_backend"] }
duniter-gva-db = { path = "../../rust-libs/modules/gva/db", default-features = false, features = ["explorer", "leveldb_backend"] }
......
......@@ -14,7 +14,7 @@ path = "src/lib.rs"
[dependencies]
anyhow = "1.0.34"
duniter-dbs = { path = "../duniter-dbs" }
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
resiter = "0.4.0"
[dev-dependencies]
......
......@@ -6,5 +6,5 @@ license = "AGPL-3.0"
edition = "2018"
[dependencies]
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
serde = { version = "1.0.105", features = ["derive"] }
......@@ -13,7 +13,7 @@ path = "src/lib.rs"
[dependencies]
chrono = "0.4.19"
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
duniter-dbs = { path = "../duniter-dbs" }
fast-threadpool = "0.2.3"
log = "0.4.11"
......
......@@ -16,7 +16,7 @@ arrayvec = "0.5.1"
bincode = "1.2.1"
byteorder = "1.3.4"
chrono = { version = "0.4.15", optional = true }
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
kv_typed = { path = "../tools/kv_typed", default-features = false }
log = "0.4.8"
mockall = { version = "0.9.1", optional = true }
......
......@@ -12,7 +12,7 @@ edition = "2018"
path = "src/lib.rs"
[dependencies]
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
duniter-dbs = { path = "../duniter-dbs" }
duniter-bc-reader = { path = "../duniter-bc-reader" }
duniter-dbs-write-ops = { path = "../duniter-dbs-write-ops" }
......
......@@ -8,7 +8,7 @@ edition = "2018"
[dependencies]
anyhow = "1.0.34"
async-trait = "0.1.41"
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
duniter-conf = { path = "../duniter-conf" }
duniter-dbs = { path = "../duniter-dbs" }
duniter-mempools = { path = "../duniter-mempools" }
......
......@@ -8,7 +8,7 @@ edition = "2018"
[dependencies]
anyhow = "1.0.34"
cfg-if = "1.0.0"
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
duniter-conf = { path = "../duniter-conf" }
duniter-dbs = { path = "../duniter-dbs" }
duniter-bc-reader = { path = "../duniter-bc-reader" }
......
......@@ -12,7 +12,7 @@ async-graphql = "2.2.0"
async-mutex = "1.4.0"
async-trait = "0.1.41"
bytes = "1.0"
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
duniter-bca = { path = "./bca" }
duniter-conf = { path = "../../duniter-conf" }
duniter-dbs = { path = "../../duniter-dbs" }
......
......@@ -10,7 +10,7 @@ anyhow = "1.0.33"
async-bincode = "0.6.1"
async_io_stream = { version = "0.3.1", features = [ "tokio_io"] }
bincode = "1.3"
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
duniter-bca-types = { path = "types", features = ["duniter"] }
duniter-dbs = { path = "../../../duniter-dbs" }
duniter-gva-db = { path = "../db" }
......
......@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
bincode = "1.3"
dubp = { version = "0.49.0" }
dubp = { version = "0.50.0" }
serde = { version = "1.0.105", features = ["derive"] }
smallvec = { version = "1.4.0", features = ["serde"] }
thiserror = "1.0.20"
......
......@@ -14,7 +14,7 @@ path = "src/lib.rs"
bincode = "1.2.1"
chrono = { version = "0.4.15", optional = true }
duniter-dbs = { path = "../../../duniter-dbs" }
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
kv_typed = { path = "../../../tools/kv_typed", default-features = false, features = ["sled_backend"] }
parking_lot = "0.11.0"
paste = "1.0.2"
......
......@@ -49,6 +49,12 @@ impl WalletHashWithBnV1Db {
u32::from_be_bytes(unsafe { std::mem::transmute(buffer) })
}
pub fn wallet_hash_interval(wallet_hash: Hash) -> (Self, Self) {
(
Self::new(wallet_hash, BlockNumber(0)),
Self::new(wallet_hash, BlockNumber(u32::MAX)),
)
}
}
impl Default for WalletHashWithBnV1Db {
......
......@@ -19,7 +19,7 @@ anyhow = "1.0.34"
arrayvec = "0.5.1"
duniter-dbs = { path = "../../../duniter-dbs" }
duniter-gva-db = { path = "../db" }
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
mockall = { version = "0.9.1", optional = true }
resiter = "0.4.0"
......
......@@ -10,7 +10,7 @@ anyhow = "1.0.33"
arrayvec = "0.5.1"
async-graphql = "2.2.0"
async-trait = "0.1.41"
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
duniter-conf = { path = "../../../duniter-conf" }
duniter-dbs = { path = "../../../duniter-dbs" }
duniter-bc-reader = { path = "../../../duniter-bc-reader" }
......
......@@ -102,8 +102,7 @@ impl GenTxsQuery {
String,
>,
issuer: PubKeyGva,
#[graphql(desc = "Recipient address (Ed25519 public key on base 58 representation)")]
recipient: PubKeyGva,
#[graphql(desc = "Recipient address")] recipient: PkOrScriptGva,
#[graphql(desc = "Use mempool sources", default = false)] use_mempool_sources: bool,
) -> async_graphql::Result<Vec<String>> {
let comment = comment.unwrap_or_default();
......
......@@ -15,7 +15,7 @@ path = "src/lib.rs"
anyhow = "1.0.34"
duniter-dbs = { path = "../../../duniter-dbs" }
duniter-gva-db = { path = "../db" }
dubp = { version = "0.49.0", features = ["duniter"] }
dubp = { version = "0.50.0", features = ["duniter"] }
once_cell = "1.5.2"
resiter = "0.4.0"
......
......@@ -243,6 +243,7 @@ mod tests {
documents::transaction::TransactionDocumentV10Stringified,
documents_parser::prelude::FromStringObject,
};
#[test]
fn test_gva_apply_block() -> anyhow::Result<()> {
let gva_db = GvaV1Db::<Mem>::open(MemConf::default())?;
......@@ -412,6 +413,7 @@ mod tests {
Ok(())
}
#[test]
fn test_gva_revert_block() -> anyhow::Result<()> {
let gva_db = GvaV1Db::<Mem>::open(MemConf::default())?;
......@@ -467,7 +469,6 @@ mod tests {
number: 2,
version: 10,
median_time: 5_247,
dividend: Some(1000),
transactions: vec![TransactionDocumentV10Stringified {
currency: "test".to_owned(),
blockstamp: "0-0000000000000000000000000000000000000000000000000000000000000000".to_owned(),
......@@ -476,8 +477,7 @@ mod tests {
inputs: vec!["400:0:T:0000000000000000000000000000000000000000000000000000000000000000:1".to_owned()],
unlocks: vec![],
outputs: vec![
"300:0:SIG(D9D2zaJoWYWveii1JRYLVK3J4Z7ZH3QczoKrnQeiM6mx)".to_owned(),
"100:0:SIG(4fHMTFBMo5sTQEc5p1CNWz28S4mnnqdUBmECq1zt4n2m)".to_owned(),
"400:0:SIG(4fHMTFBMo5sTQEc5p1CNWz28S4mnnqdUBmECq1zt4n2m)".to_owned(),
],
comment: "".to_owned(),
signatures: vec![],
......@@ -491,6 +491,62 @@ mod tests {
apply_block(&b2, &gva_db)?;
let b3 = DubpBlockV10::from_string_object(&DubpBlockV10Stringified {
number: 3,
version: 10,
median_time: 5_249,
transactions: vec![TransactionDocumentV10Stringified {
currency: "test".to_owned(),
blockstamp: "0-0000000000000000000000000000000000000000000000000000000000000000".to_owned(),
locktime: 0,
issuers: vec!["4fHMTFBMo5sTQEc5p1CNWz28S4mnnqdUBmECq1zt4n2m".to_owned()],
inputs: vec!["400:0:T:0101010101010101010101010101010101010101010101010101010101010101:0".to_owned()],
unlocks: vec![],
outputs: vec![
"400:0:SIG(D9D2zaJoWYWveii1JRYLVK3J4Z7ZH3QczoKrnQeiM6mx)".to_owned(),
],
comment: "".to_owned(),
signatures: vec![],
hash: Some("0202020202020202020202020202020202020202020202020202020202020202".to_owned()),
}],
inner_hash: Some("0000000A65A12DB95B3153BCD05DB4D5C30CC7F0B1292D9FFBC3DE67F72F6040".to_owned()),
signature: "7B0hvcfajE2G8nBLp0vLVaQcQdQIyli21Gu8F2l+nimKHRe+fUNi+MWd1e/u29BYZa+RZ1yxhbHIbFzytg7fAA==".to_owned(),
hash: Some("0000000000000000000000000000000000000000000000000000000000000000".to_owned()),
..Default::default()
})?;
apply_block(&b3, &gva_db)?;
revert_block(&b3, &gva_db)?;
assert_eq!(gva_db.blockchain_time().count()?, 3);
assert_eq!(gva_db.blockchain_time().get(&U32BE(2))?, Some(5_247));
assert_eq!(gva_db.balances().count()?, 2);
assert_eq!(
gva_db.balances().get(&WalletConditionsV2(s1.clone()))?,
Some(SourceAmountValV2(SourceAmount::ZERO))
);
assert_eq!(
gva_db.balances().get(&WalletConditionsV2(s2.clone()))?,
Some(SourceAmountValV2(SourceAmount::with_base0(1_000)))
);
assert_eq!(gva_db.gva_utxos().count()?, 2);
assert_eq!(
gva_db
.gva_utxos()
.iter(.., |it| it.collect::<KvResult<Vec<_>>>())?,
vec![
(
GvaUtxoIdDbV1::new(s2.clone(), 1, Hash::default(), 0),
SourceAmountValV2(SourceAmount::with_base0(600))
),
(
GvaUtxoIdDbV1::new(s2.clone(), 2, Hash([1u8; 32]), 0),
SourceAmountValV2(SourceAmount::with_base0(400))
),
]
);
revert_block(&b2, &gva_db)?;
assert_eq!(gva_db.blockchain_time().count()?, 2);
......@@ -525,15 +581,12 @@ mod tests {
assert_eq!(gva_db.blockchain_time().count()?, 1);
assert_eq!(gva_db.blockchain_time().get(&U32BE(0))?, Some(5_243));
assert_eq!(gva_db.balances().count()?, 2);
assert_eq!(gva_db.balances().count()?, 1);
assert_eq!(
gva_db.balances().get(&WalletConditionsV2(s1))?,
Some(SourceAmountValV2(SourceAmount::with_base0(1000)))
);
assert_eq!(
gva_db.balances().get(&WalletConditionsV2(s2))?,
Some(SourceAmountValV2(SourceAmount::with_base0(0)))
);
assert_eq!(gva_db.balances().get(&WalletConditionsV2(s2))?, None);
Ok(())
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment