codemod --extensions rs loader_program_id loader
This commit is contained in:
parent
e702515312
commit
49f4be6a2b
|
@ -166,7 +166,7 @@ mod tests {
|
|||
userdata,
|
||||
program_id,
|
||||
executable: true,
|
||||
loader_program_id: Pubkey::default(),
|
||||
loader: Pubkey::default(),
|
||||
},
|
||||
),
|
||||
(alice_pubkey, Account::new(100, 0, program_id)),
|
||||
|
@ -204,7 +204,7 @@ mod tests {
|
|||
userdata,
|
||||
program_id,
|
||||
executable: true,
|
||||
loader_program_id: Pubkey::default(),
|
||||
loader: Pubkey::default(),
|
||||
};
|
||||
let alice_account = Account::new(100, 0, program_id);
|
||||
let serialize_account = Account {
|
||||
|
@ -212,7 +212,7 @@ mod tests {
|
|||
userdata: read_test_file("serialize.lua"),
|
||||
program_id,
|
||||
executable: false,
|
||||
loader_program_id: Pubkey::default(),
|
||||
loader: Pubkey::default(),
|
||||
};
|
||||
let mut accounts = [
|
||||
(Pubkey::default(), program_account),
|
||||
|
@ -246,7 +246,7 @@ mod tests {
|
|||
userdata: read_test_file("multisig.lua"),
|
||||
program_id,
|
||||
executable: true,
|
||||
loader_program_id: Pubkey::default(),
|
||||
loader: Pubkey::default(),
|
||||
};
|
||||
|
||||
let alice_account = Account {
|
||||
|
@ -254,7 +254,7 @@ mod tests {
|
|||
userdata: Vec::new(),
|
||||
program_id,
|
||||
executable: true,
|
||||
loader_program_id: Pubkey::default(),
|
||||
loader: Pubkey::default(),
|
||||
};
|
||||
|
||||
let serialize_account = Account {
|
||||
|
@ -262,7 +262,7 @@ mod tests {
|
|||
userdata: read_test_file("serialize.lua"),
|
||||
program_id,
|
||||
executable: true,
|
||||
loader_program_id: Pubkey::default(),
|
||||
loader: Pubkey::default(),
|
||||
};
|
||||
|
||||
let mut accounts = [
|
||||
|
|
|
@ -16,7 +16,7 @@ pub struct Account {
|
|||
pub executable: bool,
|
||||
|
||||
/// the loader for this program (Pubkey::default() for no loader)
|
||||
pub loader_program_id: Pubkey,
|
||||
pub loader: Pubkey,
|
||||
}
|
||||
|
||||
impl Account {
|
||||
|
@ -27,7 +27,7 @@ impl Account {
|
|||
userdata: vec![0u8; space],
|
||||
program_id,
|
||||
executable: false,
|
||||
loader_program_id: Pubkey::default(),
|
||||
loader: Pubkey::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -821,7 +821,7 @@ impl Bank {
|
|||
Some(program) => program,
|
||||
None => return Err(BankError::AccountNotFound),
|
||||
};
|
||||
if !program.executable || program.loader_program_id == Pubkey::default() {
|
||||
if !program.executable || program.loader == Pubkey::default() {
|
||||
return Err(BankError::AccountNotFound);
|
||||
}
|
||||
|
||||
|
@ -829,7 +829,7 @@ impl Bank {
|
|||
keys.insert(0, program_id);
|
||||
accounts.insert(0, program.clone());
|
||||
|
||||
program_id = program.loader_program_id;
|
||||
program_id = program.loader;
|
||||
}
|
||||
|
||||
let mut keyed_accounts: Vec<_> = (&keys)
|
||||
|
@ -2025,7 +2025,7 @@ mod tests {
|
|||
let string = transport_receiver.poll();
|
||||
assert!(string.is_ok());
|
||||
if let Async::Ready(Some(response)) = string.unwrap() {
|
||||
let expected = format!(r#"{{"jsonrpc":"2.0","method":"accountNotification","params":{{"result":{{"executable":false,"loader_program_id":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"program_id":[129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tokens":1,"userdata":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},"subscription":0}}}}"#);
|
||||
let expected = format!(r#"{{"jsonrpc":"2.0","method":"accountNotification","params":{{"result":{{"executable":false,"loader":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"program_id":[129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"tokens":1,"userdata":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},"subscription":0}}}}"#);
|
||||
assert_eq!(expected, response);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,6 @@ pub fn account() -> Account {
|
|||
program_id: id(),
|
||||
userdata: BPF_LOADER_NAME.as_bytes().to_vec(),
|
||||
executable: true,
|
||||
loader_program_id: native_loader::id(),
|
||||
loader: native_loader::id(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -488,7 +488,7 @@ mod tests {
|
|||
"tokens": 20,
|
||||
"userdata": [],
|
||||
"executable": false,
|
||||
"loader_program_id": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
||||
"loader": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
||||
},
|
||||
"id":1}
|
||||
"#;
|
||||
|
|
|
@ -401,7 +401,7 @@ mod tests {
|
|||
let contract_funds = Keypair::new();
|
||||
let contract_state = Keypair::new();
|
||||
let budget_program_id = BudgetState::id();
|
||||
let loader_program_id = Pubkey::default(); // TODO
|
||||
let loader = Pubkey::default(); // TODO
|
||||
let executable = false; // TODO
|
||||
let bank = Bank::new(&alice);
|
||||
let arc_bank = Arc::new(bank);
|
||||
|
@ -489,7 +489,7 @@ mod tests {
|
|||
"tokens": 1,
|
||||
"userdata": expected_userdata,
|
||||
"executable": executable,
|
||||
"loader_program_id": loader_program_id,
|
||||
"loader": loader,
|
||||
|
||||
},
|
||||
"subscription": 0,
|
||||
|
@ -530,7 +530,7 @@ mod tests {
|
|||
"tokens": 51,
|
||||
"userdata": expected_userdata,
|
||||
"executable": executable,
|
||||
"loader_program_id": loader_program_id,
|
||||
"loader": loader,
|
||||
},
|
||||
"subscription": 0,
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ mod tests {
|
|||
"tokens": 1,
|
||||
"userdata": expected_userdata,
|
||||
"executable": executable,
|
||||
"loader_program_id": loader_program_id,
|
||||
"loader": loader,
|
||||
},
|
||||
"subscription": 0,
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ impl SystemProgram {
|
|||
accounts[1].program_id = program_id;
|
||||
accounts[1].userdata = vec![0; space as usize];
|
||||
accounts[1].executable = false;
|
||||
accounts[1].loader_program_id = Pubkey::default();
|
||||
accounts[1].loader = Pubkey::default();
|
||||
}
|
||||
SystemProgram::Assign { program_id } => {
|
||||
if !Self::check_id(&accounts[0].program_id) {
|
||||
|
@ -112,11 +112,11 @@ impl SystemProgram {
|
|||
accounts[1].tokens += tokens;
|
||||
}
|
||||
SystemProgram::Spawn => {
|
||||
if !accounts[0].executable || accounts[0].loader_program_id != Pubkey::default()
|
||||
if !accounts[0].executable || accounts[0].loader != Pubkey::default()
|
||||
{
|
||||
Err(Error::AccountNotFinalized)?;
|
||||
}
|
||||
accounts[0].loader_program_id = accounts[0].program_id;
|
||||
accounts[0].loader = accounts[0].program_id;
|
||||
accounts[0].program_id = tx.account_keys[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@ pub fn account() -> Account {
|
|||
program_id: id(),
|
||||
userdata: ERC20_NAME.as_bytes().to_vec(),
|
||||
executable: true,
|
||||
loader_program_id: native_loader::id(),
|
||||
loader: native_loader::id(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue