mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-01-21 11:31:09 +03:00
64e8c48c35
* create 2.0.0 branch * V0/V1 Slate Removal + Grin Header Version Bump (#140) * Remove V0 and V1 Slates from Wallet * rustfmt * V1 API + V2 wallet to wallet impl (#144) * remove v1 API * rustfmt * convert http adapter to use V2 api * rustfmt * V2 API conversion Pt2 - Check version (#146) * call check_version on wallet before http send * rustfmt * Support new Bulletproof rewind scheme (#122) * Restore with LegacyProofBuilder * Switch to ProofBuilder at HF block * Switch proof builder for coinbase outputs at hard fork * Use valid_header_version to switch proof builder * Fix compilation errors * Use legacy proof builder for AutomatedTesting chain type * Add macro to avoid duplicate code * Read version info from server, react accordingly (#154) * read and parse version, bump hf * rustfmt * add foreign api middleware check * rustfmt * add middleware checks * rustfmt * add check for incoming pre-hf slates * api tests * Add double rewind period (#155) * Add double rewind period * Simplify restore * Fix comment * bump imported version for beta release * version bump for next (potential) release * Provide more specific error when other wallet is outdated (#162) * add appropriate error message when other wallet is out of date * rustfmt * missing cargo.lock
96 lines
2.9 KiB
Rust
96 lines
2.9 KiB
Rust
// Copyright 2019 The Grin Developers
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
//! core::libtx specific tests
|
|
//use grin_wallet_libwallet::Slate;
|
|
|
|
// test all slate conversions
|
|
/* TODO: Turn back on upon release of new slate version
|
|
#[test]
|
|
fn slate_conversions() {
|
|
// Test V0 to V2
|
|
let v0 = include_str!("slates/v0.slate");
|
|
let res = Slate::deserialize_upgrade(&v0);
|
|
assert!(res.is_ok());
|
|
// should serialize as latest
|
|
let mut res = res.unwrap();
|
|
assert_eq!(res.version_info.orig_version, 0);
|
|
res.version_info.orig_version = 2;
|
|
let s = serde_json::to_string(&res);
|
|
assert!(s.is_ok());
|
|
let s = s.unwrap();
|
|
let v = Slate::parse_slate_version(&s);
|
|
assert!(v.is_ok());
|
|
assert_eq!(v.unwrap(), 2);
|
|
println!("v0 -> v2: {}", s);
|
|
|
|
// Test V1 to V2
|
|
let v1 = include_str!("slates/v1.slate");
|
|
let res = Slate::deserialize_upgrade(&v1);
|
|
assert!(res.is_ok());
|
|
// should serialize as latest
|
|
let mut res = res.unwrap();
|
|
assert_eq!(res.version_info.orig_version, 1);
|
|
res.version_info.orig_version = 2;
|
|
let s = serde_json::to_string(&res);
|
|
assert!(s.is_ok());
|
|
let s = s.unwrap();
|
|
let v = Slate::parse_slate_version(&s);
|
|
assert!(v.is_ok());
|
|
assert_eq!(v.unwrap(), 2);
|
|
println!("v1 -> v2: {}", s);
|
|
|
|
// V2 -> V2, check version
|
|
let v2 = include_str!("slates/v2.slate");
|
|
let res = Slate::deserialize_upgrade(&v2);
|
|
assert!(res.is_ok());
|
|
let res = res.unwrap();
|
|
assert_eq!(res.version_info.orig_version, 2);
|
|
let s = serde_json::to_string(&res);
|
|
assert!(s.is_ok());
|
|
let s = s.unwrap();
|
|
let v = Slate::parse_slate_version(&s);
|
|
assert!(v.is_ok());
|
|
assert_eq!(v.unwrap(), 2);
|
|
|
|
// Downgrade to V1
|
|
let v2 = include_str!("slates/v2.slate");
|
|
let res = Slate::deserialize_upgrade(&v2);
|
|
assert!(res.is_ok());
|
|
let mut res = res.unwrap();
|
|
// downgrade
|
|
res.version_info.orig_version = 1;
|
|
let s = serde_json::to_string(&res);
|
|
assert!(s.is_ok());
|
|
let s = s.unwrap();
|
|
let v = Slate::parse_slate_version(&s);
|
|
assert!(v.is_ok());
|
|
assert_eq!(v.unwrap(), 1);
|
|
println!("v2 -> v1: {}", s);
|
|
|
|
// Downgrade to V0
|
|
let v2 = include_str!("slates/v2.slate");
|
|
let res = Slate::deserialize_upgrade(&v2);
|
|
assert!(res.is_ok());
|
|
let mut res = res.unwrap();
|
|
// downgrade
|
|
res.version_info.orig_version = 0;
|
|
let s = serde_json::to_string(&res);
|
|
assert!(s.is_ok());
|
|
let s = s.unwrap();
|
|
let v = Slate::parse_slate_version(&s);
|
|
assert!(v.is_ok());
|
|
assert_eq!(v.unwrap(), 0);
|
|
println!("v2 -> v0: {}", s);
|
|
}
|
|
*/
|