I'm trying to return a dynamic array of structures from a Solidity function to a client. Since I need to build the result, I'm declaring a storage variable and add elements to it:
function conversations(address user) public view returns (Conversation[]){
Conversation[] userConversations;
userConversations.push(conversations[0]);
return userConversations;
}
However, I keep getting an out of gas exception in my Truffle tests. How can it run out of gas when it's a view function? I understand that userConversations is a storage variable (or I won't be able to execute push on it), but does it really modify the state of the contract? If it does, how do you rewrite it so that you can get a dynamic array?