diff --git a/src/common/balances.lua b/src/common/balances.lua index 8f97ca8..e3a12d2 100644 --- a/src/common/balances.lua +++ b/src/common/balances.lua @@ -12,7 +12,7 @@ function balances.transfer(to) Balances = { [to] = 1 } Owner = to Controllers = {} - return "Transfer successful" + return json.encode({ [to] = 1 }) end function balances.balance(address) @@ -28,13 +28,11 @@ end function balances.setName(name) assert(type(name) == "string", "Name must be a string") Name = name - return "Name set to " .. name end function balances.setTicker(ticker) assert(type(ticker) == "string", "Ticker must be a string") Ticker = ticker - return "Ticker set to " .. ticker end return balances diff --git a/src/common/controllers.lua b/src/common/controllers.lua index b1a7f27..432d4f8 100644 --- a/src/common/controllers.lua +++ b/src/common/controllers.lua @@ -11,7 +11,7 @@ function controllers.setController(controller) end table.insert(Controllers, controller) - return "Controller added" + return json.encode(Controllers) end function controllers.removeController(controller) @@ -27,7 +27,6 @@ function controllers.removeController(controller) end assert(controllerExists ~= nil, "Controller does not exist") - return "Controller removed" end function controllers.getControllers() diff --git a/src/common/initialize.lua b/src/common/initialize.lua index d4d34e7..d4b69ec 100644 --- a/src/common/initialize.lua +++ b/src/common/initialize.lua @@ -31,13 +31,13 @@ function initialize.initializeANTState(state) Records = records Initialized = true - return { + return json.encode({ name = Name, ticker = Ticker, balances = Balances, controllers = Controllers, records = Records, - } + }) end local function findObject(array, key, value) diff --git a/src/common/main.lua b/src/common/main.lua index 3349383..6081c7d 100644 --- a/src/common/main.lua +++ b/src/common/main.lua @@ -304,7 +304,7 @@ function ant.init() ao.send({ Target = msg.From, Data = result, Error = "Initialize-State-Error", ["Message-Id"] = msg.Id }) return else - ao.send({ Target = msg.From, Data = json.encode(result) }) + ao.send({ Target = msg.From, Data = result }) end end ) diff --git a/test/controllers.test.js b/test/controllers.test.js index 2e8d289..60a8a38 100644 --- a/test/controllers.test.js +++ b/test/controllers.test.js @@ -41,7 +41,7 @@ describe('aos Controllers', async () => { ], }); - assert(result.Messages[0].Data === 'Controller added'); + assert(JSON.parse(result.Messages[0].Data).includes(controller), true); }); it('Should remove the controller', async () => { @@ -52,7 +52,7 @@ describe('aos Controllers', async () => { ], }); - assert(result.Messages[0].Data === 'Controller removed'); + assert(result); const addControllerResult = await handle( { @@ -63,6 +63,9 @@ describe('aos Controllers', async () => { }, result.Memory, ); - assert.equal(addControllerResult.Messages[0].Data, 'Controller added'); + assert.equal( + JSON.parse(addControllerResult.Messages[0].Data).includes(STUB_ADDRESS), + true, + ); }); });