Permalink
Browse files

Allow sender balance to equal the amount sent in the token contract

Thanks Steve!
  • Loading branch information...
masonforest committed Dec 5, 2018
1 parent 911bd15 commit b7c38c2fd73329d5d8701fd1feef5d920cf291f5
@@ -1,6 +1,7 @@
[workspace]
members = [
"base_api",
"user_contracts",
"human_readable_name_registry",
"base_token",
"leader_election"
BIN -131 Bytes (100%) base_token/dist/base_token.wasm
Binary file not shown.
@@ -22,7 +22,7 @@ pub fn transfer(receiver_address: Vec<u8>, amount: u64) -> Result<(), Error> {
let sender_balance = read_int(sender());
let receiver_balance = read_int(receiver_address.clone());

if sender_balance > amount {
if sender_balance => amount {
write_int(sender(), sender_balance - amount);
write_int(receiver_address, receiver_balance + amount);
Ok(())
@@ -21,22 +21,6 @@ extern crate wee_alloc;
#[cfg(not(test))]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[cfg(not(test))]
use core::panic::PanicInfo;

#[cfg(not(test))]
#[panic_implementation]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}

#[cfg(not(test))]
#[alloc_error_handler]
fn out_of_memory(_: ::core::alloc::Layout) -> ! {
loop {}
}


mod error;

#[cfg(not(test))]
@@ -1,4 +1,4 @@
const WasmRPC = require('/Users/masonf/src/simple-wasm').default;
const WasmRPC = require('/Users/masonf/src/js-wasm-rpc-client').default;
const { execFileSync } = require('child_process');
const cbor = require('cbor');
const { StringDecoder } = require('string_decoder');
@@ -14,6 +14,7 @@ class FakeBlockchain extends WasmRPC {
_read: (keyPtr) => {
var key = this.readPointer(keyPtr);
if(this.storage[key]) {
// console.log(`${key} -> ${this.storage[key]}`)
return this.writePointer(this.storage[key]);
} else {
return this.writePointer(new Uint8Array([]));
@@ -23,6 +24,7 @@ class FakeBlockchain extends WasmRPC {
var key = this.readPointer(keyPtr);
var value = this.readPointer(valuePtr);

// console.log(`${key} = ${value}`)
this.storage[key] = value;
},
throw: console.log,
@@ -17,7 +17,7 @@ describe('BaseToken', function() {
defaultSender: SENDER,
});

await blockchain.loadFile("../target/wasm32-unknown-unknown/release/base_token.wasm");
await blockchain.loadFile("dist/base_token.wasm");
});

afterEach(() => blockchain.reset());
Binary file not shown.

0 comments on commit b7c38c2

Please sign in to comment.